Skip to content
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

Module '"react"' has no exported member 'experimental_useOptimistic'. #57026

Closed
1 task done
grzegorzpokorski opened this issue Oct 19, 2023 · 4 comments
Closed
1 task done
Labels
bug Issue was opened via the bug report template. locked TypeScript Related to types with Next.js. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

Comments

@grzegorzpokorski
Copy link

grzegorzpokorski commented Oct 19, 2023

Link to the code that reproduces this issue

https://github.com/grzegorzpokorski/useoptimistic-issue

To Reproduce

  1. clone repo
  2. pnpm i && pnpm lint && pnpm build
  3. you shouldn't see any errors after pnpm lint but build fails with following error:

Module '"react"' has no exported member 'experimental_useOptimistic'.

Current vs. Expected behavior

successfully build app

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: 8.9.2
Relevant Packages:
  next: 13.5.6
  eslint-config-next: 13.5.6
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure, ESLint (eslint-config-next)

Additional context

Recently React team removed experimantal_ prefix from some hooks facebook/react#27459.
I see that Next.js uses under hood experimental version of the React library where useOptimistic does not require prefix but at build is used stable version of React what causes error and fails build (?)

@grzegorzpokorski grzegorzpokorski added the bug Issue was opened via the bug report template. label Oct 19, 2023
@balazsorban44 balazsorban44 added the TypeScript Related to types with Next.js. label Oct 19, 2023
@balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 added the Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). label Oct 19, 2023
@balazsorban44
Copy link
Member

This is not something Next.js could fix at the moment, as our version of React does not match with those types yet. You can pin the types to "@types/react": "18.2.26" for now.

@karlhorky
Copy link
Contributor

The change to remove the experimental_ prefix (see diff below) is now working in the latest Next.js canary version (currently next@13.5.7-canary.23)

-import { experimental_useFormStatus as useFormStatus } from 'react-dom';
+import { useFormStatus } from 'react-dom';

Copy link
Contributor

github-actions bot commented Nov 8, 2023

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Nov 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked TypeScript Related to types with Next.js. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

No branches or pull requests

3 participants