dillon1000/react

Commit

InferReactivePlaces account for immutable aliases of mutably aliased values

I found this by adding logic to reject inputs where reactivity gets newly 
propagated in PruneNonReactiveDependencies. It's possible to create a readonly 
alias to a mutable value such that we don't know the value is reactive yet when 
the alias is created. Thus we need to do a fixpoint iteration even if there are 
no loops in order to be able to revisit such aliases and reflow the reactivity 
forward. Example: 

```javascript 

const x = []; 

const y = x; 

const z = [y]; // y isn't reactive yet when we first visit this, so z is 
initially non-reactive 

y.push(props.value); // then we realize y is reactive. we need a fixpoint to 
propagate this back to z 

const a = [z]; // need an indirection to get past the partial propagation in 
PruneNonReactiveDependencies 

let b = 0; 

if (a[0][0]) { 

b = 1; 

} 

return [b]; 

``` 

Existing fixtures don't change because the basic reactivity propagation in 
PruneNonReactiveDependencies is enough to make common cases work. I confirmed 
that the new fixture does not work on previous PR in the stack.
Browse files
Changed paths3 files
First-parent comparison
M compiler/packages/babel-plugin-react-forget/src/Inference/InferReactivePlaces.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactivity-via-readonly-alias-of-mutable-value.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reactivity-via-readonly-alias-of-mutable-value.js Added
Patch

Files changed

Rendering syntax-highlighted changes…