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
|
// eslint-disable-next-line flowtype/no-weak-types
|
||||||
export default class UiItem<I:Object>
|
export default class UiItem<I:Object>
|
||||||
extends React.PureComponent<UiItemProps<I>> {
|
extends React.Component<UiItemProps<I>> {
|
||||||
constructor(props: UiItemProps<I>) {
|
constructor(props: UiItemProps<I>) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +82,12 @@ export class UiControl<I: UIControl> extends UiItem<I> {
|
||||||
trailing: true
|
trailing: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// $FlowFixMe
|
||||||
|
shouldComponentUpdate(nextProps: UiItemProps<I>) { // TODO: Fix Flow
|
||||||
|
return nextProps.state[nextProps.item.topic] !==
|
||||||
|
this.props.state[this.props.item.topic];
|
||||||
|
}
|
||||||
|
|
||||||
getValue() {
|
getValue() {
|
||||||
const control = this.props.item;
|
const control = this.props.item;
|
||||||
const topic: string = control.topic || "";
|
const topic: string = control.topic || "";
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ export default class UiItemList extends React.PureComponent<UiItemListProps> {
|
||||||
|
|
||||||
renderControl(control: ControlUI, key: string, mqtt: MqttContextValue) {
|
renderControl(control: ControlUI, key: string, mqtt: MqttContextValue) {
|
||||||
const props = {
|
const props = {
|
||||||
state: mqtt.state,
|
state: Object.assign({}, mqtt.state),
|
||||||
onChangeState: mqtt.changeState,
|
onChangeState: mqtt.changeState,
|
||||||
key: `${key}-licontrol`
|
key: `${key}-licontrol`
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue