Skip to content

Instantly share code, notes, and snippets.

@tomatau
Last active August 29, 2015 14:17
Show Gist options
  • Save tomatau/1f32c147bb95be27fae0 to your computer and use it in GitHub Desktop.
Save tomatau/1f32c147bb95be27fae0 to your computer and use it in GitHub Desktop.
Component Refs
let MyForm = React.createClass({
render(){
return (
<form onSubmit={this.handleSubmit}>
<input type="text" ref='my-input' />
</form>
)
},
handleSubmit(event){
event.preventDefault()
let myInputRef = this.refs['my-input'];
let myInputNode = React.findDOMNode(myInputRef)
console.log(myInputNode)
let inputValue = myInputNode.value;
console.log(inputValue)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment