Refactor SettingsCheckbox

This commit is contained in:
Alex Gleason 2020-04-22 22:08:12 -05:00
parent a6de9d5e00
commit 924486984e
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -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}
/>
);