'use strict'; import React from 'react'; let InputCheckbox = React.createClass({ propTypes: { required: React.PropTypes.bool, defaultChecked: React.PropTypes.bool, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element ]).isRequired }, getDefaultProps() { return { defaultValue: false }; }, getInitialState() { return { value: this.props.defaultChecked }; }, componentDidMount() { this.props.onChange({ target: { value: this.state.value } }); }, onChange() { let value = !this.refs.checkbox.getDOMNode().checked; this.setState({value: value}); this.props.onChange({ target: { value: value } }); }, render() { return ( {this.props.children} ); } }); export default InputCheckbox;