-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Bug]: (v7) Prerendering Fails with React 19 #12138
Comments
This can still be reproduced with the latest stable versions of React and React Router. Updated repro link: https://stackblitz.com/edit/vitejs-vite-wlza4m?file=package.json&terminal=build Logs❯ npm run build
> react-router build
vite v6.0.3 building for production...
✓ 41 modules transformed.
build/client/.vite/manifest.json 1.11 kB │ gzip: 0.32 kB
build/client/assets/home-DMjzBprG.js 0.18 kB │ gzip: 0.17 kB
build/client/assets/with-props-BxDUxdVQ.js 0.44 kB │ gzip: 0.22 kB
build/client/assets/root-Dj_cnf6b.js 0.52 kB │ gzip: 0.32 kB
build/client/assets/chunk-D52XG6IA-CIXPXIh-.js 103.03 kB │ gzip: 34.93 kB
build/client/assets/entry.client-BOCz0HeL.js 179.29 kB │ gzip: 56.87 kB
✓ built in 1.38s
vite v6.0.3 building SSR bundle for production...
✓ 8 modules transformed.
build/server/.vite/manifest.json 0.17 kB
build/server/index.js 5.43 kB
TypeError: dispatcher.getOwner is not a function
[getOwner@/node_modules/react/cjs/react.development.js#cjs:416:54
exports.createElement@/node_modules/react/cjs/react.development.js#cjs:1330:61
getRouteComponents@/node_modules/react-router/dist/development/index.js#cjs:6209:104
createServerRoutes/<@/node_modules/react-router/dist/development/index.js#cjs:6229:10
createServerRoutes@/node_modules/react-router/dist/development/index.js#cjs:6222:45
ServerRouter@/node_modules/react-router/dist/development/index.js#cjs:8215:34
…
TypeError: dispatcher.getOwner is not a function
[getOwner@/node_modules/react/cjs/react.development.js#cjs:416:54
exports.createElement@/node_modules/react/cjs/react.development.js#cjs:1330:61
getRouteComponents@/node_modules/react-router/dist/development/index.js#cjs:6209:104
createServerRoutes/<@/node_modules/react-router/dist/development/index.js#cjs:6229:10
createServerRoutes@/node_modules/react-router/dist/development/index.js#cjs:6222:45
ServerRouter@/node_modules/react-router/dist/development/index.js#cjs:8215:34
…
x Build failed in 276ms
[react-router] Prerender: Received a 500 status code from `entry.server.tsx` while prerendering the `/` path.
Unexpected Server Error
at validatePrerenderedResponse (/node_modules/@react-router/dev/dist/vite.js:2635:11)
at prerenderRoute (/node_modules/@react-router/dev/dist/vite.js:2599:30) {
code: 'PLUGIN_ERROR',
plugin: 'react-router',
hook: 'writeBundle'
} |
I have found a simple way to fix this issue is to run
It seems like this issue is related to this : #12078 |
@Fredkiss3 is correct, this is the way to force the proper NODE_ENV for React to build correctly To be determined if we change how the defaults are setup, so I'll leave this issue open. However, for anyone looking at this issue, this is a proper solution (also true if you have |
This also affects Just mentioning since this issue and linked PR helped me understand and fix. |
|
This should be fixed by #12578 and available in the next release |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
@brophdawg11 - I really appreciated this emphasis. I had not shifted my thinking to this given I was still in "client react router" headspace. Can we add something to https://reactrouter.com/how-to/spa along those lines? I could open an issue/PR if desired. Separately, awesome to hear about |
What version of React Router are you using?
7.0.0-pre.1
Steps to Reproduce
pnpm build
Expected Behavior
It should build successfully.
Actual Behavior
It fails with a cryptic error likely due to React's internals changing.
The text was updated successfully, but these errors were encountered: