mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Adds a new `LabelTerminal` which will be used to represent LabeledStatements that contain a statement other than a loop. What we do for these cases is basically break the containing block in two, with a goto after the inner statement to the fallthrough. This allows us to model the label, and any `break` to it, in the HIR. However this fails in codegen because we can't find the fallthrough branch — we need a high level terminal that knows about this structure. Hence LabelTerminal. Now, instead of just a continuation block and a goto, we have a structured terminal. The LabelTerminal expresses the block for the labeled statement and the continuation, and we can use this to put it back together when constructing a ReactiveFunction. Note that this PR is just the scaffolding for LabelTerminal, the next PR is the interesting bits.
test262
@ 83a46bfe0e
React Forget
React Forget is an experimental Babel plugin to automatically memoize React Hooks and Components.
Development
# tsc --watch
$ yarn dev
# in another terminal window
$ yarn test --watch
Notes
An overview of the implementation can be found in the Architecture Overview.
This transform
- needs plugin-syntax-jsx as a dependency to inherit the syntax from.
- should be run before plugin-transform-react-jsx
- assume the enforcement of rules of hooks, i.e.
- only call hooks from React functions
- only call hooks at the top level
- https://www.npmjs.com/package/eslint-plugin-react-hooks
Scaffolding
- https://github.com/facebook/flow/tree/master/packages/babel-plugin-transform-flow-enums
- https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts
Reference