Created
August 18, 2016 16:24
-
-
Save llopez/ee1023672f4f219fa8b37b24a8ec6067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Form extends React.Component { | |
_fill(e) { | |
console.log(e.target.value); | |
} | |
render() { | |
return( | |
<form> | |
{this.props.children} | |
</form> | |
); | |
} | |
} | |
class Field extends React.Component { | |
_setValue(e) { | |
this.props.fill(e); | |
} | |
render() { | |
return ( | |
<input type="text" onChange={this._setValue}/> | |
); | |
} | |
} | |
render( | |
<Form> | |
<Field name="first_name" /> | |
<Field name="last_name" /> | |
</Form>, | |
document.getElementById('form1') | |
); | |
render( | |
<Form> | |
<Field name="first_name" /> | |
<Field name="last_name" /> | |
<Field name="age" /> | |
</Form>, | |
document.getElementById('form2') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment