Small performance optimization
This commit is contained in:
parent
c7202a9141
commit
21e246c98a
2 changed files with 8 additions and 2 deletions
|
|
@ -32,7 +32,7 @@ type UiItemProps<I> = {
|
|||
|
||||
// eslint-disable-next-line flowtype/no-weak-types
|
||||
export default class UiItem<I:Object>
|
||||
extends React.PureComponent<UiItemProps<I>> {
|
||||
extends React.Component<UiItemProps<I>> {
|
||||
constructor(props: UiItemProps<I>) {
|
||||
super(props);
|
||||
}
|
||||
|
|
@ -82,6 +82,12 @@ export class UiControl<I: UIControl> extends UiItem<I> {
|
|||
trailing: true
|
||||
});
|
||||
|
||||
// $FlowFixMe
|
||||
shouldComponentUpdate(nextProps: UiItemProps<I>) { // 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 || "";
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export default class UiItemList extends React.PureComponent<UiItemListProps> {
|
|||
|
||||
renderControl(control: ControlUI, key: string, mqtt: MqttContextValue) {
|
||||
const props = {
|
||||
state: mqtt.state,
|
||||
state: Object.assign({}, mqtt.state),
|
||||
onChangeState: mqtt.changeState,
|
||||
key: `${key}-licontrol`
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue