question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shallow renderer does not support React.memo

See original GitHub issue

Do 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:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
gaearoncommented, Feb 10, 2019

memo() can be used with any component type. Happy to take a PR that adds support for it!

3reactions
gaearoncommented, Mar 22, 2019

Fixed in 16.8.5.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found