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