We are getting the React checksum invalid when using graphql HOC with Fela library. Fela relies on the execution order to generate atomic classes.
Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
(client) >
The only workaround I know of is to use fela-monolithic enhancer https://github.com/rofrischmann/fela/tree/master/packages/fela-monolithic
Not a permanent solution though.
Try calling renderer.clear() in between getDataFromTree() and renderToString(). This should work 👍
So roughly:
const renderer = createRenderer();
const jsx = <MyApp/>;
await getDataFromTree(jsx);
renderer.clear();
return renderToString(jsx);
The reason you need to call renderer.clear() is that getDataFromTree() will do a lightweight render of your app in order to get all of the data queries you are planning to execute. This lightweight render generates all of Fela’s CSS classes. By the time you render a second time, Fela’s internal “offset” for CSS classes is off by one render, so you need to reset the internal offset.
@calebmer it works! Thank you, sir!
@calebmer Awesome it works like a charm. Thank you!
Most helpful comment
Try calling
renderer.clear()in betweengetDataFromTree()andrenderToString(). This should work 👍So roughly:
The reason you need to call
renderer.clear()is thatgetDataFromTree()will do a lightweight render of your app in order to get all of the data queries you are planning to execute. This lightweight render generates all of Fela’s CSS classes. By the time you render a second time, Fela’s internal “offset” for CSS classes is off by one render, so you need to reset the internal offset.