Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Is there a benefit to removing existing memoization code? #16

Discussion options

You must be logged in to vote

It is generally safe to leave manual memoization in your code – the compiler understands it but will compile in its own lower-level form of memoization even for manually memoized code. The compiler does however check its memoization against manual memoization to ensure that we memoized it exactly the same. The reason we need to do this is in case the manual memoization was used for correctness. For example, if a manually memoized value was passed as a dependency to a useEffect call somewhere else and it wasn't memoized in the same way, this might cause over/under firing of effects or even infinite loops.

For this reason, our current recommendation is to leave manual memoization in for exi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@codemonkeynorth
Comment options

Answer selected by rynobax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants