dillon1000/react
Commit
Browse files Repro for unmemoized array due to mutation surrounding hook
Distilled repro of an internal example we found. Forget determines a mutable range for the array, but that mutable range spans a hook call, so the reactive scope gets pruned. That's all working as expected. What isn't ideal though is that if we know `x` is an array and `f` can't mutate its arguments, then `x.map(f)` shouldn't count as a mutation of `x`, since Array.prototype.map can only mutate the receiver via the callback (if the callback mutates its args). Improving on this example requires a) we have to know it's an Array, via type information or bc we saw an array literal and b) being precise about which functions could possibly mutate their parameters, which is tricky because of indirect mutations via stores, etc.
Changed paths3 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-missing-memoization-unmodified-array.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-missing-memoization-unmodified-array.js AddedPatch
Files changed
Rendering syntax-highlighted changes…