-
I came across a weird thing I don't really understand regarding routing. I have 3 components, Blue, Yellow and Red. Color components are really simple, just a color name, some style and class:
When we hit So far so good. The button will route to The result: Still okay, yellow and red are rendered as expected. At first it flashes with the text |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This seems to be a hydration problem (mismatch between the React code rendered in the server, and the one rendered in the client).
The Location state you are using is explained in the React Router V6 documentation here. I guess that as Remix does not know that information on server side. When you hit reload, the server renders your page first thinking it's the Blue component. Then that comes to the client and is displayed immediately by the browser as Blue. And when the client side JavaScript loads it "hydrates" the existing DOM with the client side React code, which results in something a bit different: the Red component. And only a part of it is changed, the I don't know if this has to be considered as a bug or not 🤔 Maybe Remix could send the |
Beta Was this translation helpful? Give feedback.
This seems to be a hydration problem (mismatch between the React code rendered in the server, and the one rendered in the client).
When reloading with the weird behavior I get this error:
The Location state you are using is explained in the React Router V6 documentation here.
It is created on client side, and seems to be kept by your browser until you change the URL, or put the same URL by hand after changing it.
I guess that as Remix does not know that information on server side. When you hit reload, the server renders your page first thinking it's the Blue component. Then that comes to the client and is displayed imme…