Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

core-dialog: Unique tag name triggers React hydration warning #256

Closed
esseb opened this issue May 27, 2019 · 4 comments
Closed

core-dialog: Unique tag name triggers React hydration warning #256

esseb opened this issue May 27, 2019 · 4 comments

Comments

@esseb
Copy link

esseb commented May 27, 2019

I get this warning when using @nrk/[email protected] in react16.8.6 in dev mode:

react-dom.development.js:506 Warning: Expected server HTML to contain a matching <coredialog-jw688k8f156> in <div>.

The React documentation about hydration says that "you should treat mismatches as bugs and fix them"

As far as I can tell from the source this is because the element's tag name is a generated UUID based on the current time, which will naturally differ between server and client.

Is there an option I can use to ensure this unique tag name is identical between the server and the client? The generic tag name core-dialog with no UUID would be enough for my purposes so I would be fine with a solution where I could disable the unique tag.

@eirikbacker
Copy link
Contributor

Not good enough for other users, but we can solve this with version-number instead :) @htor

@esseb
Copy link
Author

esseb commented May 27, 2019

Something like a version number would be fine :)

@htor
Copy link
Contributor

htor commented May 28, 2019

@esseb can you confirm this works in latest master? thanks

@esseb
Copy link
Author

esseb commented May 28, 2019

@htor latest master (3b864c8) looks fine.

The custom element is now rendered with the tag name core-dialog-react on both server and client. No warning from React (other than #261 which is unrelated).

Closing.

@esseb esseb closed this as completed May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants