onlyUpdateForStateKeys?
mqklin opened this issue · 2 comments
mqklin commented
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.
istarkov commented
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.
mqklin commented
Sure. Thank you for the answer!