diff --git a/src/components/UiItemList/UiItem.js b/src/components/UiItemList/UiItem.js index 2fc6c11..c0d11d8 100644 --- a/src/components/UiItemList/UiItem.js +++ b/src/components/UiItemList/UiItem.js @@ -32,7 +32,7 @@ type UiItemProps = { // eslint-disable-next-line flowtype/no-weak-types export default class UiItem - extends React.PureComponent> { + extends React.Component> { constructor(props: UiItemProps) { super(props); } @@ -82,6 +82,12 @@ export class UiControl extends UiItem { trailing: true }); + // $FlowFixMe + shouldComponentUpdate(nextProps: UiItemProps) { // TODO: Fix Flow + return nextProps.state[nextProps.item.topic] !== + this.props.state[this.props.item.topic]; + } + getValue() { const control = this.props.item; const topic: string = control.topic || ""; diff --git a/src/components/UiItemList/index.js b/src/components/UiItemList/index.js index eeacf6c..e2d433d 100644 --- a/src/components/UiItemList/index.js +++ b/src/components/UiItemList/index.js @@ -62,7 +62,7 @@ export default class UiItemList extends React.PureComponent { renderControl(control: ControlUI, key: string, mqtt: MqttContextValue) { const props = { - state: mqtt.state, + state: Object.assign({}, mqtt.state), onChangeState: mqtt.changeState, key: `${key}-licontrol` };