Server-side rendering doesn't work
See original GitHub issueWhen using SSR with ReactDOMServer.renderToString
I get following exception:
Invariant Violation: Could not find "store" in the context of "Connect(ConnectedRouterWithContext)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(ConnectedRouterWithContext) in connect options.
at invariant (/home/user/app/node_modules/invariant/invariant.js:40:15)
at Connect.renderWrappedComponent (/home/user/app/node_modules/react-redux/lib/components/connectAdvanced.js:162:32)
at ReactDOMServerRenderer.render (/home/user/app/dist/node_modules/react-dom/cjs/react-dom-server.node.development.js:2494:55)
at ReactDOMServerRenderer.read (/home/user/app/dist/node_modules/react-dom/cjs/react-dom-server.node.development.js:2357:19)
at Object.renderToString (/home/user/app/dist/node_modules/react-dom/cjs/react-dom-server.node.development.js:2729:25)
at renderToString (/home/user/app/dist/server/webpack:/src/server/indexServer.js:220:18)
Dependencies:
"connected-react-router": "6.0.0",
"react": "16.7.0",
"react-dom": "16.7.0",
"react-redux": "6.0.0",
"react-router-dom": "4.3.1",
"redux": "4.0.1",
Compoents:
<Provider store={store}>
<ErrorCatcher>
<ConnectedRouter history={history}>
<Switch>
<Route path="/recorder/" component={Recorder} />
<Route path="/" component={Regular} />
</Switch>
</ConnectedRouter>
</ErrorCatcher>
</Provider>
Rendering client-side only works.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12
Top Results From Across the Web
Server-side rendering not working on production in Next.js ...
When using server-side rendering with next@12.1.6, the context doesn't get passed down to the children component.
Read more >Server-side rendering not working on production Next.js
If I understand it correctly, my code is located at the main home page at pages/index.tsx. Does this page not support getServerSideProps ?...
Read more >Why doesn't React.useEffect run on React server-side renders ...
The conclusion that React. useEffect doesn't run during a server-side render (SSR) is left to the reader however.
Read more >What is server-side rendering and how does it improve site ...
Server -side rendering ensures that website content appears quickly, without first having to download and run application code.
Read more >Server-Side Rendering (SSR) - Vue.js
For example, if you are building an internal dashboard where an extra few hundred milliseconds on initial load doesn't matter that much, SSR...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Me too, without SSR
You may want to use
<StaticRouter>
on the server side. Here’s an example from a repo that adds SSR to a non-ejected CRA starter app. https://github.com/cereallarceny/cra-ssr/blob/master/server/loader.js