All files / src/Control Checkbox.jsx

100% Statements 6/6
100% Branches 0/0
100% Functions 3/3
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28            4x 4x 4x 4x         2x               3x          
import * as React from 'react';
import Base from './Base';
 
class Checkbox extends React.Component {
  static defaultProps = {
    component: props => {
      let controlProps = {...props.controlProps};
      let children = controlProps.children;
      delete controlProps['children'];
      return (
        <div>
          <input 
              {...controlProps}
              type='checkbox'
              onChange={e => controlProps.onChange(e, e.target.checked)}/>
          {children}
        </div>
      )
    },
    initialValue: false
  }
  render() {
    return <Base {...this.props} initialValue={this.props.initialValue}/>;
  }
}
 
export default Checkbox;