electrode-samples / hapi-react-redux

Hapi boilerplate application for demostrating integration of Electrode standalone modules
8 stars 4 forks source link

Server side rendering discarded #8

Open santhoshmahalingam opened 7 years ago

santhoshmahalingam commented 7 years ago

Hi,

I am getting an issue as Server-side React render was discarded. Make sure that your initial render does not contain any client-side code.

Can you help me on this.

Thanks in advance.

Santhosh

raydecastro commented 7 years ago

@santhoshmahalingam are you getting that error from cloning the repo and running it? or from following the instructions and building it from scratch?

I think I've experienced a similar issue once before, and it was related to the following (as mentioned in the readme):

GOTCHA:

SSR caching of components only works in PRODUCTION mode, since the props(which are read only) are mutated for caching purposes and mutating of props is not allowed in development mode by react.

Make sure the electrode-react-ssr-caching module is imported first followed by the imports of react and react-dom module. SSR caching will not work if the ordering is changed since caching module has to have a chance to patch react's code first. Also if you are importing electrode-react-ssr-caching, react and react-dom in the same file , make sure you are using all require or all import. Found that SSR caching was NOT working if, electrode-react-ssr-caching is required first and then react and react-dom is imported.

santhoshmahalingam commented 7 years ago

@raydecastro , Thanks for your response. I am new to react and electrode. I made two mistakes that i was looking for SSR caching in dev mode as well SSR caching module imported after react. It works fine for me now, Thanks.

But i have an another problem that while trying load DOM from api calls following hapi-universal-redux I didnt get the DOM for SEO. Because the page loads before i receive api response in my page.

Can you help me on this.

Thanks,