leebenson / reactql

Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
https://reactql.org
MIT License
1.82k stars 173 forks source link

Hydrate on Static Deploy #170

Closed jasonlor closed 5 years ago

jasonlor commented 5 years ago

Hey there!

Is it possible to hydrate in static mode? The only reference I was able to find is I want to leverage a different backend than Koa and SSR render the data from the server.

ReactDOM[root.innerHTML ? "hydrate" : "render"] in client.tsx

leebenson commented 5 years ago

I'm not sure what you mean, exactly.

Static mode, by definition, means that the output being produced includes:

In this context, there's nothing to hydrate because index.html doesn't contain any rendered React HTML. It contains an empty <div id="root"> where it will render the client-side React.

If you are foregoing the index.html and using your own backend, this placing your own SSR content inside of <div id="root"> will have the same affect. However, it would need to match the generated .js exactly, or you'll get errors that the content doesn't match.

If I'm missing the point and you mean something else, please provide some more detail. I'm not clear how you're expecting this to work.