-
-
Save jmorrell/68f6f7e1aca9c5f42f78 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
import {default as React, PropTypes} from 'react' | |
const namespace = 'sampleComponent' | |
export default class SampleComponent extends React.Component { | |
constructor(props) { | |
super(); | |
this.state = {value: ''}; | |
} | |
handleInput(event) { | |
console.log('setting state to ', event.target.value) | |
this.setState({value: event.target.value}) | |
} | |
render() { | |
console.log('render', this.state); | |
return ( | |
<div className={namespace}> | |
Name:<input type='text' onChange={this.handleInput.bind(this)} /> | |
<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