We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This might be out of the scope of the project but is it possible to do server side rendering/ rehydration with unistore?
The text was updated successfully, but these errors were encountered:
Not out-of-scope at all! I don't know that it'd end up being in the Unistore repo, but certainly I'd love to show an example of how to do it.
Here's roughly how it looks:
function serverRender() { const store = createStore(); let html = renderToString(<App store={store} />); const data = store.getState(); html = html.replace(/(<body(\s.?)?>)/, '$1<script>window.DATA='+JSON.stringify(data)+'</script>'); return html; } function clientRender() { const store = createStore(window.DATA); render(<App store={store} />, document.body); }
Sorry, something went wrong.
use devalue instead of JSON.stringify to prevent XSS
devalue
JSON.stringify
'$1<script>window.DATA='+devalue(data)+'</script>'
That is a fantastic suggestion @stereobooster.
No branches or pull requests
This might be out of the scope of the project but is it possible to do server side rendering/ rehydration with unistore?
The text was updated successfully, but these errors were encountered: