dillon1000/react

Commit

Option to assume hooks follow the rules

Adds a new feature flag which tells the compiler to assume that hooks follow the 
Rules of React. Specifically, the idea that since any hook could be wrapped in a 
giant `useMemo()` call, all arguments to hooks have to be treated as if they're 
owned by React — and therefore become immutable — and that the return value of 
the hook is immutable. 

Our default is to assume that hooks break the rules, but in practice nearly 
every component follows them.
Browse files
Changed paths9 files
First-parent comparison
M compiler/forget/packages/snap/src/compiler-worker.ts ModifiedM compiler/forget/src/HIR/Environment.ts ModifiedM compiler/forget/src/HIR/Types.ts ModifiedM compiler/forget/src/Inference/DropMemoCalls.ts ModifiedM compiler/forget/src/Inference/InferReferenceEffects.ts ModifiedM compiler/forget/src/__tests__/compiler-test.ts ModifiedA compiler/forget/src/__tests__/fixtures/compiler/immutable-hooks.expect.md AddedA compiler/forget/src/__tests__/fixtures/compiler/immutable-hooks.js AddedM compiler/forget/src/__tests__/test-utils/generateTestsFromFixtures.ts Modified
Patch

Files changed

Rendering syntax-highlighted changes…