-
Notifications
You must be signed in to change notification settings - Fork 49.9k
Description
What kind of issue is this?
- React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
- babel-plugin-react-compiler (build issue installing or using the Babel plugin)
- eslint-plugin-react-hooks (build issue installing or using the eslint plugin)
- react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro
Repro steps
In the example,
const restart = React.useCallback(() => {
if (observable) {
setObservable(recreateRef.current());
}
}, [observable]);should be fine, but the compiler complains that setObservable is missing from the dependency array, even though it is aReact.useState return value from the same hook.
The inferred dependency was
setObservable, but the source dependencies were [observable]. Inferred different dependency than source.
Apologies for the weird reproduction - I couldn't reproduce this from scratch, so it's a minimized variant of where we're seeing this in the wild: https://github.com/apollographql/apollo-client/blob/a43583377ccaae60b58bc45edfc88f32bed74a46/src/react/hooks/useSubscription.ts#L375
I know that on it's own, the reproduction doesn't make a lot of sense, but if I leave any of the leftover building blocks out, everything works nicely.
How often does this bug happen?
Every time
What version of React are you using?
19.1.0, but likely irrelevant - this is a library with peerDependency 17-19
What version of React Compiler are you using?
1.0.0/playground