Question
Can't import { useActionState } from 'react' following next.js tutorial, next.js v15.0.0-canary.28, react v19.0.0-rc, types/react v18.2.21
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/react@18.3.3
and now it works.