Skip to content

Instantly share code, notes, and snippets.

@shicky
Created June 17, 2016 06:38
Show Gist options
  • Save shicky/1b481560c87d022d7edcd8c9839f6745 to your computer and use it in GitHub Desktop.
Save shicky/1b481560c87d022d7edcd8c9839f6745 to your computer and use it in GitHub Desktop.
const React = require('react');
// sample callback
function onCheckboxClicked(e, id) {
console.log(e.target.id);
console.log(e.target.checked);
//store.dispatch(ReduxActions.updateSomething(something));
}
const CheckboxInput = React.createClass({
getInitialState: function() {
return {
checked: this.props.checked || false
};
},
toggle: function(evt, id) {
this.setState({checked: evt.target.checked});
this.props.onClick(evt, id, true);
},
render: function() {
return (
<input
id={this.props.id}
type="checkbox"
checked={this.state.checked}
onClick={this.toggle} />
);
}
});
module.exports = CheckboxInput;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment