Skip to content

Uncaught TypeError: Cannot read properties of null (reading 'useState') when built with @vitejs/plugin-react-swc #390

Description

@BLucky-gh

When building the project with @vitejs/plugin-react-swc I'm getting the following errors:

Uncaught TypeError: Cannot read properties of null (reading 'useState')
    at react_production_min.useState (react.production.min.js:26:234)
    at useLoadGsiScript (index.esm.js:6:69)
    at GoogleOAuthProvider (index.esm.js:37:38)
    at renderWithHooks (react-dom-client.production.js:3502:21)
    at updateFunctionComponent (react-dom-client.production.js:6239:15)
    at beginWork (react-dom-client.production.js:7243:14)
    at performUnitOfWork (react-dom-client.production.js:10855:14)
    at workLoopSync (react-dom-client.production.js:10736:37)
    at renderRootSync (react-dom-client.production.js:10717:7)
    at performWorkOnRoot (react-dom-client.production.js:10322:40)

which is thrown in the GoogleOAuthProvider

running in dev mode, or building with @vitejs/plugin-react (the esbuld/babel one) doesn't cause this issue, this is exclusive to @vitejs/plugin-react-swc built with vite build

extra context:
versions:
vite: 7.0.0 (had the same issue with vite 6)
react-oauth/google: 0.12.2
@vitejs/plugin-react: 4.6.0
@vitejs/plugin-react-swc: 3.10.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions