Hydration mismatch error: suggestion to include mismatch details in production error message #24850
Labels
Resolution: Stale
Automatically closed due to inactivity
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
After upgrading to React 18 at Unsplash, we saw lots of hydration mismatch errors in production. This was not surprising because React now logs these as errors whereas before they were development-only warnings.
However, when we looked at the errors in Sentry, there was no information in the error message to help us reproduce the problem. It seemed that the mismatches only occurred in very specific circumstances.
React does log this useful information but unfortunately it's only logged in the development build:
react/packages/react-dom/src/client/ReactDOMComponent.js
Lines 234 to 248 in 229c86a
We made a small patch to
react-dom
to add the same information to the production error message. This made it easy to see that the issue was because our date formatting produced different results depending on the user's time zone:I would like to suggest that this information is included in the production error message—presumably this would be useful debugging information for others React users.
Related discussion: #11189
The text was updated successfully, but these errors were encountered: