mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[compiler] Check if local identifier is a hook when resolving globals
When resolving import specifiers from the react namespace (`import {imported as local} from 'react'`), we were previously only checking if the `imported` identifier was a hook if we didn't already have its definition in the global registry. We also need to check if `local` is a hook in the case of aliasing since there may be hook-like APIs in react that don't start with `use` (eg they are experimental or unstable).
This commit is contained in:
@@ -852,7 +852,9 @@ export class Environment {
|
||||
*/
|
||||
return (
|
||||
this.#globals.get(binding.imported) ??
|
||||
(isHookName(binding.imported) ? this.#getCustomHookType() : null)
|
||||
(isHookName(binding.imported) || isHookName(binding.name)
|
||||
? this.#getCustomHookType()
|
||||
: null)
|
||||
);
|
||||
} else {
|
||||
const moduleType = this.#resolveModuleType(binding.module, loc);
|
||||
|
||||
Reference in New Issue
Block a user