Hacker News new | ask | show | jobs
by beaconstudios 1701 days 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.
2 comments

In which case, I stand corrected. I’ve not used React for a while and wasn’t aware that was possible.
But 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