andreiduca / cra-ssr-code-splitting

Demo code for Server Side Rendering and Code Splitting in a create-react-app.
https://medium.com/bucharestjs/upgrading-a-create-react-app-project-to-a-ssr-code-splitting-setup-9da57df2040a
221 stars 70 forks source link

crashing on start #1

Closed gmchaturvedi1 closed 6 years ago

gmchaturvedi1 commented 6 years ago

image

andreiduca commented 6 years ago

Please clone/download this repo in a clean directory, then follow the instruction in the README file:

yarn install
yarn run build
yarn run server

You need to run the server app with yarn run server. Running just yarn start will not work because __SERVER_REDUX_STATE__ is not overwritten by the node server (yarn start is not running the node server!), so you'll get at least an error for undefined variable.

Please read the articles linked in the README file. As clearly explained there, __SERVER_REDUX_STATE__ is just a placeholder that the express app has to overwrite. Of course, you'll get an error if you just run the app without the server, because window.__REDUX_STATE__ = __SERVER_REDUX_STATE__ is not valid.

Again, this repo is not for react development, but just to demonstrate how SSR and code-splitting can be achieved!