3 ms·
the parent doesn't have to memoise the component though. You can do this: export default React.memo(function myComponent(props) { // implementation
by beaconstudios 5y ago
the parent doesn't have to memoise the component though. You can do this:
export default React.memo(function myComponent(props) {
// implementation
});
though you would likely want to set displayName before exporting, in reality.
- jon-wood 5y agoIn which case, I stand corrected. I’ve not used React for a while and wasn’t aware that was possible.
- FalconSensei 5y agoBut that is still memo-ing, just in a different part of the code. And I'm not sure wrapping all components in React.memo is a good practice, otherwise all components would be memo-ed by default. `shouldComponentUpdate` is more explicit