From ee6f8ffdc214a6677b627a68c186e042b7091e4b Mon Sep 17 00:00:00 2001 From: raboid Date: Mon, 7 Jan 2019 17:51:01 -0500 Subject: [PATCH] Update ListSetting to use util/toggle --- components/ListSetting.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/components/ListSetting.js b/components/ListSetting.js index 1573001..b1f2435 100644 --- a/components/ListSetting.js +++ b/components/ListSetting.js @@ -1,24 +1,19 @@ import React from 'react' + import Checkmark from './svg/Checkmark' import { COLORS } from '../lib/constants' +import { toggle } from '../lib/util' class ListSetting extends React.Component { - constructor(props) { - super(props) - this.state = { isVisible: false } - this.select = this.select.bind(this) - this.toggle = this.toggle.bind(this) - } + state = { isVisible: false } - select(item) { - if (this.props.selected !== item) { - this.props.onChange(item) + select = id => { + if (this.props.selected !== id) { + this.props.onChange(id) } } - toggle() { - this.setState({ isVisible: !this.state.isVisible }) - } + toggle = () => this.setState(toggle('isVisible')) renderListItems() { return this.props.items.map(item => (