Refactor SettingsCheckbox
This commit is contained in:
parent
a6de9d5e00
commit
924486984e
1 changed files with 5 additions and 8 deletions
|
@ -14,26 +14,23 @@ export default @connect(mapStateToProps)
|
|||
class SettingsCheckbox extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
label: PropTypes.string,
|
||||
path: PropTypes.array.isRequired,
|
||||
settings: ImmutablePropTypes.map.isRequired,
|
||||
}
|
||||
|
||||
handleCheckboxSetting = path => {
|
||||
const { dispatch } = this.props;
|
||||
return (e) => {
|
||||
dispatch(changeSetting(path, e.target.checked));
|
||||
onChange = path => {
|
||||
return e => {
|
||||
this.props.dispatch(changeSetting(path, e.target.checked));
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const { label, path, settings, ...props } = this.props;
|
||||
const { settings, path, ...props } = this.props;
|
||||
|
||||
return (
|
||||
<Checkbox
|
||||
label={label}
|
||||
checked={settings.getIn(path)}
|
||||
onChange={this.handleCheckboxSetting(path)}
|
||||
onChange={this.onChange(path)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue