Skip to content

Beta 0.30 bug: React 19 version mismatch - TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher') #937

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

Closed
kodobrody opened this issue Nov 17, 2024 · 5 comments · Fixed by #938

Comments

@kodobrody
Copy link

kodobrody commented Nov 17, 2024

Describe the bug

⨯ node_modules\react-calendar-timeline\dist\react-calendar-timeline.es.js (195:1) @ eval
 ⨯ TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher')
    at __webpack_require__ (C:\Users\adamm\react-calendar-test\.next\server\webpack-runtime.js:33:42)
    at eval (./src/app/test.tsx:7:81)
    at (ssr)/./src/app/test.tsx (C:\Users\adamm\react-calendar-test\.next\server\app\page.js:159:1)
    at Object.__webpack_require__ [as require] (C:\Users\adamm\react-calendar-test\.next\server\webpack-runtime.js:33:42)
digest: "2676660959"
  193 |       }
  194 |     }
> 195 |     var ke = V.ReactCurrentDispatcher, je;
      | ^
  196 |     function ze(g, D, H) {
  197 |       {
  198 |         if (je === void 0)

To Reproduce

  1. Initialize next.js project (it defaults to react 19 and next.js 15, when tried in vite it works fine as it uses react 18)
  2. Install 0.30@beta-1
  3. setup basic example (I'm using date-fns for dates with .valueOf() to get numbers)

OR

Steps to reproduce the behavior:

  1. Go to page
  2. See an error

Expected behavior
It should render the component correctly

Screenshots
image

Library Version
0.30 beta 1

@kodobrody kodobrody changed the title Beta 0.30 bug: TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher') Beta 0.30 bug: React 19 version mismatch - TypeError: Cannot read properties of undefined (reading 'ReactCurrentDispatcher') Nov 17, 2024
@Remco4EF
Copy link
Contributor

I did some testing rebuilding the lib against react 19 (which is rc at the moment if i am not wrong). At that time it starts working somewhat but i run into the nextjs problem of it not allowing global stylesheets from a package.

@kodobrody if you lower the react version to 18 with nextjs in your package.json, does the whole app work as expected?

I also cannot get it convinced to import the stylesheet explicitly.
Can anyone give some pointers for that?

@KlotzJesse
Copy link
Contributor

@Remco4EF

Can be fixed by correctly not bundling any react in the vite.config.mjs external option, like that:
external: ["react", /^react\/.*/, "react-dom", /react-dom\/.*/],

@kodobrody
Copy link
Author

kodobrody commented Nov 22, 2024

@Remco4EF @Ilaiwi could you incorporate this change? Also strange thing, because after lowering the react version to latest 18 (18.3.1) it still shows the same error.

@KlotzJesse
Copy link
Contributor

@kodobrody react 19 is being forced with nextjs 15 :)

you can verify why it is a problem by finding __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner in the dist of the package in npm

The reason why it breaks is because __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED were changed in react 19, which leads to a problem and react version mismatch, because __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED is undefined, and nextjs15 is using react 19 rc

We actually also can just mark react-jsx-runtime also as external :)

minimum / recommended for react18/19 therefore:
external: ['react', 'react/jsx-runtime', 'react-dom', 'react-dom/client']

helped at cal.com to also reduce bundle size from 20kb to 2kb :)

@Ilaiwi
Copy link
Collaborator

Ilaiwi commented Nov 24, 2024

released in 0.30.0-beta.2

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

Successfully merging a pull request may close this issue.

4 participants