dillon1000/react

Commit

Support hooks/methods on the React namespace

Allows using hooks/methods off of the `React` namespace, for example 
`React.useState(sathya)`. Thanks to the previous PR we correctly handle things 
like validation of hooks called via propertyload syntax. The main change here is 
to teach the compiler about the `React` namespace. This is a bit of a hack since 
we treat it as a global, but we're transforming React code so this seems 
reasonable (?). 

There are a few additional touch-ups which I'll do in subsequent PRs to make 
review easier. For example, we need to teach our useMemo/useCallback flattening 
logic to also handle the case of `React.useMemo()` etc.
Browse files
Changed paths12 files
First-parent comparison
M compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/Globals.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md AddedR compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.babel-existing-react-namespace-import.js →compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.js RenamedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.babel-existing-react-namespace-import.expect.md DeletedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.hooks-with-React-namespace.expect.md DeletedD compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.hooks-with-React-namespace.js DeletedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-React-namespace.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-React-namespace.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/react-namespace.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/react-namespace.js AddedM compiler/packages/sprout/src/shared-runtime.ts Modified
Patch

Files changed

Rendering syntax-highlighted changes…