-
Notifications
You must be signed in to change notification settings - Fork 50.2k
[compiler] Consider setter from useOptimistic non-reactive #35141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[compiler] Consider setter from useOptimistic non-reactive #35141
Conversation
| isUseReducerType(id) || // dispatcher | ||
| type_.shapeId === 'BuiltInUseTransition' // startTransition | ||
| type_.shapeId === 'BuiltInUseTransition' || // startTransition | ||
| isUseOptimisticType(id) // setOptimistic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh idk what this function is doing and why some hooks use type._shapeId directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we just didn't add isFooType() helpers for all the types checked here
|
|
||
| export function isUseOptimisticType(id: Identifier): boolean { | ||
| return ( | ||
| id.type.kind === 'Function' && id.type.shapeId === 'BuiltInUseOptimistic' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id.type will be Object i think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched this to Object, but both seem to work. The real fix was adding it here:
react/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
Lines 1966 to 1970 in 6bf1a07
| case 'useActionState': | |
| case 'useRef': | |
| case 'useTransition': | |
| case 'useOptimistic': | |
| return true; |
…35141) Closes facebook#35138 DiffTrain build for [0972e23](facebook@0972e23)
…35141) Closes facebook#35138 DiffTrain build for [0972e23](facebook@0972e23)
Closes #35138