ReactElement key differs on server and client renders
ciaranw opened this issue · 3 comments
I'm using mdast-react in an isomorphic react app. I'm getting warnings from React on the client about the server-generated markup differing from what the client generated. I've tracked this down to the fact that the key counter used in h.js resets on every client render, but persists on the server renders. This leads to the counter increasing with every subsequent server render, which causes React to generate non-matching data-reactid attributes on elements.
A potential solution to this might be to initialise a counter in the Compiler constructor, and then use that to source the key from. Quite happy to submit a pull request but thought I should check in case you have a cleaner/better solution?
A potential solution to this might be to initialise a counter in the Compiler constructor, and then use that to source the key from.
👍 yep, this sounds like the right path.
Yup, should be fixed!