MomenSherif / react-oauth

Google OAuth2 using the new Google Identity Services SDK for React 🚀
https://www.npmjs.com/package/@react-oauth/google
MIT License
1.13k stars 141 forks source link

Facing issues after install: Invalid hook call. Cannot read property of null (reading 'useState'). #358

Closed Saraphite closed 4 months ago

Saraphite commented 4 months ago

Hey there!

I've recently added this package to my project and have followed the docs (twice) and I still end up with the same issue.

These are the errors: image

This is all I've added. (ClientId is redacted) image

If I remove the above then my application works again.

I'm using React 18.3.1 and Vite.js 5.2.0.

Please forgive me if I'm missing something obvious - I'm fairly new to front end development.

Saraphite commented 4 months ago

I managed to resolve this by doing one of the following things, though I'm not sure which one:

  1. Restarted my computer
  2. Deleted node_modules and then npm install
  3. Tried building a duplicate project with the same dependencies to see when it would break (spoilers; it didn't).
  4. Watched Oppenheimer
  5. Had a good nights sleep.

If you're facing a similar issue, I'd recommend trying the above.