diff --git a/components/input/readme.md b/components/input/readme.md index 97b9ea9b..d5e4a998 100644 --- a/components/input/readme.md +++ b/components/input/readme.md @@ -9,18 +9,18 @@ import Input from 'react-toolbox/lib/input'; class InputTest extends React.Component { state = { name: '', phone: '', email: '', hint: '' }; - handleChange = (name, value) => { - this.setState({ [name]: value }); + handleChange = (value, ev) => { + this.setState({ [ev.target.name]: value }); }; render () { return (
- + - - - J} /> + + + J} />
); } diff --git a/docs/app/components/layout/main/modules/examples/input_example_1.txt b/docs/app/components/layout/main/modules/examples/input_example_1.txt index 80cdde52..c16db922 100644 --- a/docs/app/components/layout/main/modules/examples/input_example_1.txt +++ b/docs/app/components/layout/main/modules/examples/input_example_1.txt @@ -1,20 +1,21 @@ class InputTest extends React.Component { state = { name: '', phone: '', multiline: '', email: '', hint: '', label: '' }; - handleChange = (name, value) => { - this.setState({...this.state, [name]: value}); + handleChange = (value, ev) => { + this.setState({[ev.target.name]: value}); }; render () { return (
- - + + - - - - + + + + + {/* Just an example. Defining functions in a property, such as onClick, is a bad idea: */} Error!! { e.preventDefault(); console.log('some help'); }}>?} />
); diff --git a/spec/components/input.js b/spec/components/input.js index 8801cdf4..d3e40c41 100644 --- a/spec/components/input.js +++ b/spec/components/input.js @@ -12,8 +12,8 @@ class InputTest extends React.Component { multilineRows: 'A\n\B\nC\nD\nE\nF', }; - handleChange = (name, value) => { - this.setState({ ...this.state, [name]: value }); + handleChange = (value, ev) => { + this.setState({[ev.target.name]: value }); }; render() { @@ -23,18 +23,19 @@ class InputTest extends React.Component {

lorem ipsum...

- + - - + + - - - + + + ); }