onlyUpdateForStateKeys?
mqklin opened this issue · comments
Is there an analogue for state?
Example:
@onlyUpdateForStateKeys('someOption')
will add check for state.someOptions
inside shouldComponentUpdate
:
shouldComponentUpdate(undefined, nextState) {
const {someOption} = this.state;
if (someOption === nextState.someOption) {
return false;
}
}
Use case: if I use setState
it will call render
each time, even if someOption
haven't been changed. The HOC will prevent this extra render call.
you have HOC(Component)
state
is in the component instance,
HOC have zero ability to access or change instance methods because of it's definition. It's a wrapper not mixin.
Sure. Thank you for the answer!