Re:React v16.6.0: lazy, memo and contextType
by throwaway3265 on Tuesday October 23, 2018 @09:14PM
(#18288906)
Is React.memo comparing deeply/recursive or at least deterministic JSON.stringify comparison? Or still going for shallow comparison?
[ Parent
| on HN ]
Re:React v16.6.0: lazy, memo and contextType
by sophiebits on Tuesday October 23, 2018 @09:15PM
(#18288917)
Still shallow.
We usually recommend avoiding deep checks because
(a) the concept of deep equality is pretty nebulous and hard to design in a predictable, precise way, and
(b) deep equality checking can be slow, often just as slow (or slower) than the actual rerender – in which case the memoization is only hurting you.
(If you want to do deep equality anyway, you can pass a second argument to React.memo to specify a custom comparator.)
Re:React v16.6.0: lazy, memo and contextType
by throwaway3265 on Thursday October 25, 2018 @01:18AM
(#18298689)
I agree about those statements, just curious since that was probably the most important concept I had to learn about "advanced" React.