You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
First of all, many thanks for this great lib, we use it a lot together with stateless function components in our production code.
We use pure and onlyUpdateForKeys API to improve render performance, btw, our use case for onlyUpdateForKeys is mainly to exclude those PropTypes.func props. And we find there is also a onlyUpdateForPropTypes. We've some questions on it.
According to https://reactjs.org/docs/typechecking-with-proptypes.html, PropTypes is a built-in typechecking abilities of React. So the purpose of PropTypes is validation but not optimization. When using onlyUpdateForPropTypes, we'll have to avoid to set PropTypes for a component's props that we don't wish it to trigger re-render, ultimately, if we set PropTypes for all props (for validation purpose), onlyUpdateForPropTypes won't help the performance improvement. This seems tricky for me.
So my questions will be:
Is it by design that onlyUpdateForPropTypes are tightly bound to PropTypes?
Is it possible to add an optional argument to onlyUpdateForPropTypes, e.g. onlyUpdateForPropTypes([PropTypes.number, PropTypes.string, PropTypes.object]), so that it will be more flexible?
Thanks.
The text was updated successfully, but these errors were encountered:
Based on my experience all that optimisations except pure is very error prone. Its sometimes not easy to get why additional props you add to existing components not updated in UI. Having few accidents we decided to not use such optimisations at all. Based on this I dont like the idea to make onlyUpdateFor* hocs more usable or general, as IMO the only good usecase to use them is some very low level controls
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, team,
First of all, many thanks for this great lib, we use it a lot together with stateless function components in our production code.
We use
pure
andonlyUpdateForKeys
API to improve render performance, btw, our use case foronlyUpdateForKeys
is mainly to exclude thosePropTypes.func
props. And we find there is also aonlyUpdateForPropTypes
. We've some questions on it.According to https://reactjs.org/docs/typechecking-with-proptypes.html,
PropTypes
is a built-in typechecking abilities of React. So the purpose ofPropTypes
is validation but not optimization. When usingonlyUpdateForPropTypes
, we'll have to avoid to set PropTypes for a component's props that we don't wish it to trigger re-render, ultimately, if we set PropTypes for all props (for validation purpose),onlyUpdateForPropTypes
won't help the performance improvement. This seems tricky for me.So my questions will be:
onlyUpdateForPropTypes
are tightly bound to PropTypes?onlyUpdateForPropTypes
, e.g.onlyUpdateForPropTypes([PropTypes.number, PropTypes.string, PropTypes.object])
, so that it will be more flexible?Thanks.
The text was updated successfully, but these errors were encountered: