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

Chapter 14 Improving Accessibility - useActionState is not available in React #775

Open
dtknepper opened this issue Jun 29, 2024 · 4 comments

Comments

@dtknepper
Copy link

Uppon importing useActionState like so:
import { useActionState } from 'react';

The following error appears:
Module '"react"' has no exported member 'useActionState'.ts(2305)

When searching on Google, the official React Documentation actually says that the useActionState is still an experimental feature in their Canary channel.

I assume this means that when using the stable version of React, this Hook is not available yet and can therefore not be used.

If I am completely wrong on this topic, please explain me what I am doing wrong! I'm not doing this course because I am so good at this all already ;)

@leerob
Copy link
Member

leerob commented Jul 6, 2024

I am not able to reproduce, can you share more about what you're seeing? Can you restart your TypeScript server?

@braxtonb
Copy link

braxtonb commented Jul 7, 2024

@dtknepper - Ran into something similar, @leerob 's suggestion to restart the Typescript server solved it on my end

The following steps may be helpful

  1. Copy final-example's package.json
  2. Run pnpm i to install latest dependencies
  3. Restart Typescript server using cmd + shift + p and select TypeScript: Restart TS Server
Screenshot 2024-07-06 at 7 58 48 PM
  1. After the TypeScript server restarts, ideally useActionState is defined
Screenshot 2024-07-06 at 7 59 45 PM
@dtknepper
Copy link
Author

I have updated all my dependancies, and I still get this error. I was however able to still continue with this project by using useFormState from the react-dom dependancy.

@braxtonb I see in you screenshot that you actually use the Canary release of React and not the general release. That's why you do not get this error.

@leerob
Copy link
Member

leerob commented Jul 7, 2024

Indeed, you are supposed to be using the canary version here (this tutorial was recently updated to Next 15 / React 19).

Those will soon be stable, but this is getting things ready ahead of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants