Skip to content

Conversation

@rickhanlonii
Copy link
Member

@rickhanlonii rickhanlonii commented Nov 14, 2025

Closes #35138

@meta-cla meta-cla bot added the CLA Signed label Nov 14, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Nov 14, 2025
isUseReducerType(id) || // dispatcher
type_.shapeId === 'BuiltInUseTransition' // startTransition
type_.shapeId === 'BuiltInUseTransition' || // startTransition
isUseOptimisticType(id) // setOptimistic
Copy link
Member Author

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?

Copy link
Member

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'
Copy link
Member

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

Copy link
Member Author

@rickhanlonii rickhanlonii Nov 17, 2025

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:

case 'useActionState':
case 'useRef':
case 'useTransition':
case 'useOptimistic':
return true;

@rickhanlonii rickhanlonii merged commit 0972e23 into facebook:main Nov 18, 2025
17 of 18 checks passed
@rickhanlonii rickhanlonii deleted the rh/use-optimistic-stable branch November 18, 2025 15:50
github-actions bot pushed a commit that referenced this pull request Nov 18, 2025
github-actions bot pushed a commit that referenced this pull request Nov 18, 2025
github-actions bot pushed a commit to code/lib-react that referenced this pull request Nov 22, 2025
github-actions bot pushed a commit to code/lib-react that referenced this pull request Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compiler Bug]: stable setter for useOptimistic

2 participants