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)
Indeed; but it doesn鈥檛 throw when you try, and it seems to work fine in actual React - I鈥檇 expect it to work, or not work, the same everywhere.
memo()
can be used with any component type. Happy to take a PR that adds support for it!
This doesn't seem to be isolated to class components, it fails with any component using memo()
: https://jsfiddle.net/f0j1e5tw/6/
The relevant tests in the open enzyme PR only fail for class components, fwiw.
Fixed in 16.8.5.
Most helpful comment
memo()
can be used with any component type. Happy to take a PR that adds support for it!