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
1 changed files with 5 additions and 8 deletions

View File

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