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

Fix eslint error #151

Merged
merged 3 commits into from
Oct 20, 2016
Merged
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
26 changes: 6 additions & 20 deletions src/FormsyText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const FormsyText = React.createClass({
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
updateImmediately: React.PropTypes.bool,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
updateImmediately: React.PropTypes.bool,
value: React.PropTypes.any,
},

Expand Down Expand Up @@ -55,14 +55,6 @@ const FormsyText = React.createClass({
return props.value || props.defaultValue || '';
},

// Controlled component
componentWillReceiveProps(nextProps) {
if (nextProps.value !== this.props.value)
this.setState({
value: nextProps.value
});
},

handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
delete this.changeValue;
Expand Down Expand Up @@ -92,14 +84,8 @@ const FormsyText = React.createClass({
}

// Controlled component
if (this.props.onChange) {
this.props.onChange(event, event.currentTarget.value);
// Uncontrolled component
} else {
this.setState({
value: event.currentTarget.value
});
}
this.setState({ value: event.currentTarget.value });
if (this.props.onChange) this.props.onChange(event, event.currentTarget.value);
},

handleKeyDown: function handleKeyDown(event) {
Expand All @@ -112,12 +98,12 @@ const FormsyText = React.createClass({
render() {
const {
defaultValue, // eslint-disable-line no-unused-vars
updateImmediately, // eslint-disable-line no-unused-vars
validations, // eslint-disable-line no-unused-vars
validationError, // eslint-disable-line no-unused-vars
validationErrors, // eslint-disable-line no-unused-vars
onFocus,
value, // eslint-disable-line no-unused-vars
...rest
...rest,
} = this.props;

return (
Expand All @@ -131,7 +117,7 @@ const FormsyText = React.createClass({
value={this.state.value}
/>
);
}
},
});

export default FormsyText;