Skip to content

porting over some react code to my project, having hydration issues #2585

Answered by gbj
Upbolt asked this question in Q&A
Discussion options

You must be logged in to vote

As you can see from the logs when you run the Leptos version, you are rendering different things on the server and the client -- is_form_control is always true on the server (because there is no DOM node to stick in the node ref), but by the time you have reached the Show on the client you have already filled the NodeRef so is_form_control is false unless it's in a <form>.

Your React code, on the other hand, renders once and then immediately renders a second time (with the setState). I am not a React user but this is what I understand is happening in your component.

Here's a Leptos version that seems to work fine and does the same thing as the React one: rendering immediately with is_form…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Upbolt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2584 on May 10, 2024 12:50.