davnicwil / react-frontload

Async data loading for React components, on client & server
451 stars 21 forks source link

Issue with the "dry run" render #8

Closed bretthadley closed 6 years ago

bretthadley commented 6 years ago

Hi,

I guess I have a specific implementation issue but some people might also have similar issue. The frontloadServerRender() calls render twice (first to fill queues then second to get the output) this is causing an issue for me with react-jss SSR (the 2 renders are causing class name conflicts and they generated css from client / server is different because of this duplicate render)

Would it be possible to just pass a boolean to the callback?

frontloadServerRender((dryRun) => { return ReactDomServer.renderToString(....) })

https://github.com/davnicwil/react-frontload/blob/master/src/index.js#L206

render(true)

my personal use for this is here

http://cssinjs.org/react-jss/?v=v8.6.1#react-tree-traversing

9

davnicwil commented 6 years ago

@bretthadley Thanks for the PR - it's been merged and a new version 1.0.2 has been published.

https://www.npmjs.com/package/react-frontload/v/1.0.2