Skip to content

Commit

Permalink
simplify boolean widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Erquhart committed May 18, 2017
1 parent 9f0967f commit 079bb92
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/components/Widgets/BooleanControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ import ImmutablePropTypes from "react-immutable-proptypes";
import Switch from 'react-toolbox/lib/switch';

export default class BooleanControl extends React.Component {

handleChange = (e) => {
this.props.onChange(e);
};

render() {
const finalValue = (this.props.value !== undefined) ? this.props.value : this.props.field.get('defaultValue', false);

return (<Switch
id={this.props.forID}
checked={finalValue}
onChange={this.handleChange}
/>);
const { value, field, forId, onChange } = this.props;
return (
<Switch
id={forId}
checked={value !== undefined ? value : field.get('defaultValue', false)}
onChange={onChange}
/>
);
}
}

Expand Down

0 comments on commit 079bb92

Please sign in to comment.