You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
jedwards1211
changed the title
Memoizing object and array literals passed to React properties, child array mapping
[Feature request?] Memoizing object and array literals passed to React properties, child array mapping
Mar 1, 2019
I'm just trying to think, because it seems like this behavior might break very easily. What if there's a condition expression? Such as cond ? a : b. The order of the hooks is essential with React hooks. I hope I'm not wrong about it. Feel free to debunk my theory
Ah, I'm sorry, I inlined the useMemo calls in my examples just to demonstrate where the memoization is being applied, and you are right, if the parent components were rendered conditionally it would cause problems. Definitely in a real implementation we would want to hoist the memoization up to the top, so for the first example:
I wanted to check if this plugin already does things like this?
Before
After
Also children can benefit from memoization too:
Before
After
The text was updated successfully, but these errors were encountered: