Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add onChangeText prop #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import TagInput from 'react-native-tag-input';
-----------------------|-----------------
| value | (Required) An array of tags |
| onChange | (Required) A handler to be called when array of emails/tags change |
| onChangeText | A handler that is called everytime the text of TextInput changes |
| regex | A RegExp to test tags after enter, space, or a comma is pressed |
| tagColor | Background color of tags |
| tagTextColor | Text color of tags |
Expand Down
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
import _ from 'lodash';

class EmailInput extends Component {
static defaultProps = {
onChangeText: () => {},
};

constructor(props) {
super(props);
let {height, width} = Dimensions.get('window');
Expand Down Expand Up @@ -76,7 +80,7 @@ class EmailInput extends Component {

if (parseWhen.indexOf(lastTyped) > -1)
this.parseEmails();
}
}

parseEmails() {
let {text} = this.state;
Expand Down Expand Up @@ -160,7 +164,7 @@ class EmailInput extends Component {
width: width,
color: inputColor
}
]} onChange={this.onChange.bind(this)} onSubmitEditing={this.parseEmails}/>
]} onChange={this.onChange.bind(this)} onChangeText={this.props.onChangeText} onSubmitEditing={this.parseEmails}/>
</View>
</View>
</TouchableWithoutFeedback>
Expand All @@ -170,6 +174,7 @@ class EmailInput extends Component {
EmailInput.PropTypes = {
onChange: React.PropTypes.func.isRequired,
value: React.PropTypes.array.isRequired,
onChangeText: React.PropTypes.func,
regex: React.PropTypes.object,
tagColor: React.PropTypes.string,
tagTextColor: React.PropTypes.string,
Expand Down