skip to Main Content

I’m following the next.js tutorial at https://nextjs.org/learn/dashboard-app

I’ve arrived at chapter 14, improving accessibility, at https://nextjs.org/learn/dashboard-app/improving-accessibility

At one point in the tutorial, it directs me to import { useActionState } from 'react'; in the /app/ui/invoices/create-form.tsx file.

When I do this, I get the error Module '"react"' has no exported member 'useActionState'.ts(2305)

I’m using next.js v15.0.0-canary.28, react v19.0.0-rc-6230622a1a-20240610, and types/react v18.2.21. As far as I know these are all the latest versions.

Does anyone know what could be the source of the error and how to correct it?

EDIT: It looks like there was a more current version of react than npm i @types/react was installing, I had to run npm i @types/[email protected] and now it works.

2

Answers


  1. I encountered the same problem, and after I ran npm i @types/[email protected], I still have the following error, not sure if you had this and if you know how to solve it?

    TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_4__.useActionState) is not a function or its return value is not iterable

    EDIT: I ran this and solved my problem npm install --legacy-peer-deps next@rc react@rc react-dom@rc

    Login or Signup to reply.
  2. @CharlesChen did your build run successfully?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search