Shallow renderer does not support React.memo
See original GitHub issueDo you want to request a feature or report a bug? bug
What is the current behavior? In normal rendering, you can memoize a class-based component: https://jsfiddle.net/586ea3cx/
With the shallow renderer, it seems like you can’t: https://jsfiddle.net/odj217Lv/1/
This might be blocking https://github.com/airbnb/enzyme/pull/1914, in which tests are failing with Cannot call a class as a function
. (it’s tough to repro stuff with the shallow renderer)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Why my shallow comparison in React.memo() is not working?
Hey I am making a food delivery app. I am currently implementing cart functionality. I am stuck memoizing the custom incrementor that I...
Read more >memo - React Docs
With memo , you can create a component that React will not re-render when its parent re-renders so long as its new props...
Read more >What is React Memo and How to Use it? - Hygraph
Use React Memo if your component will render quite often. ... React Memo makes a shallow comparison and might not function as you...
Read more >React.memo, useMemo, useCallback | Geek Culture - Medium
Do not rely on it to “prevent” a render, as this can lead to bugs. There's a reason why React.memo utilizes shallow comparison...
Read more >Use React.memo() wisely
Second render - MemoizedMovie IS NOT INVOKED. ... By default React.memo() does a shallow comparison of props and objects of props.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
memo()
can be used with any component type. Happy to take a PR that adds support for it!Fixed in 16.8.5.