Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmorrell/68f6f7e1aca9c5f42f78 to your computer and use it in GitHub Desktop.
Save jmorrell/68f6f7e1aca9c5f42f78 to your computer and use it in GitHub Desktop.
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