react
react copied to clipboard
compiler: only resolve globals and react imports
Stack from ghstack (oldest at bottom):
- -> #29190
- #29189
- #29188
Updates Environment#getGlobalDeclaration() to only resolve "globals" if they are a true global or an import from react/react-dom. We still keep the logic to resolve hook-like names as custom hooks. Notably, this means that a local Array
reference won't get confused with our Array global declaration, a local useState
(or import from something other than React) won't get confused as React.useState()
, etc.
I tried to write a proper fixture test to test that we react to changes to a custom setState setter function, but I think there may be an issue with snap and how it handles re-renders from effects. I think the tests are good here but open to feedback if we want to go down the rabbit hole of figuring out a proper snap test for this.