Skip to content
Snippets Groups Projects
Commit 3f8a65a3 authored by Mike Vitousek's avatar Mike Vitousek
Browse files

[compiler] In change detection, assign reactive scopes to values that may have...

[compiler] In change detection, assign reactive scopes to values that may have changed between renders

Summary:
Change detection is desgined to determine whether rules of react have been violated, and to do so better we need to loosen Forgets assumptions about what kinds of values don't need to be memoized. For example, the compiler typically doesn't think of o.x as something that needs to be memoized, because it does not allocate. However, we want to compare o.x in the current render with o.x in a previous one, so we now insert a "memoization" (comparison, really) block around this value.

The structure of this work is that we now add a reactive scope for identifiers if they originate from any instruction that could read from state that could have mutated between renders. This means that `LoadProperty` is always going to get a reactive scope; `LoadGlobal` will get a scope if we're not reading from something mutable, and `PrefixUpdate` won't (because the variable being incremented would have already been loaded and checked).

Supersedes #30180.

ghstack-source-id: 7f6c9899dd2180749577688480505506ce971fdd
Pull Request resolved: https://github.com/facebook/react/pull/30379
parent 47b4d333
Showing
with 287 additions and 64 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment