dillon1000/react
Commit
Browse files Support/validate hooks called as methods
Hooks can be called via method call syntax, eg `Foo.useBar(sathya)`. This PR teaches the compiler about this form of hooks for things like flattening scopes with hooks, validating conditional hooks, etc. Note that we still disallow calls on the React namespace, so things like `React.useState()` continue to error. That's the next PR in the stack!
Changed paths14 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/ObjectShape.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/FlattenScopesWithHooks.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveIdentifiers.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Validation/ValidateHooksUsage.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Validation/ValidateUnconditionalHooks.ts ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.conditional-hooks-as-method-call.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.conditional-hooks-as-method-call.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.propertyload-hook.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.propertyload-hook.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flatten-scopes-with-methodcall-hook.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flatten-scopes-with-methodcall-hook.js AddedM compiler/packages/sprout/src/shared-runtime.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…