Created
May 5, 2015 04:31
-
-
Save jmcelroy5/0a1b63622397ec59b01a to your computer and use it in GitHub Desktop.
React
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
import {default as React, PropTypes} from 'react' | |
const namespace = 'sampleComponent' | |
export default class SampleComponent extends React.Component { | |
getInitialState() { | |
return {value: ''} | |
} | |
handleInput(event) { | |
console.log('setting state to ', event.target.value) | |
this.setState({value: event.target.value}) | |
} | |
render() { | |
return <div className={namespace}> | |
Name:<input type='text' onChange={this.handleInput} /> | |
<p>Your name: {this.state.value} </p> | |
</div> | |
} | |
} | |
SampleComponent.propTypes = { | |
name: PropTypes.string.isRequired | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment