This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
checkbox does not update to checked state upon hydration and rerendering #29747
Labels
bug
Issue was opened via the bug report template.
What version of Next.js are you using?
5.0.0
What version of Node.js are you using?
14.17.5
What browser are you using?
Chrome, Firefox
What operating system are you using?
Linux
How are you deploying your application?
next start
Describe the Bug
When a checkbox is rendered serverside in the unchecked state, then it remains in the unchecked state clientside even though a rendering cycle is performed where it is checked.
Consider a page in
pages/min.js
I now visit http://localhost:3000/min?a=true
In the server-side rendering process, the query object is omitted as described in issue #8259 and elsewhere. Indeed, the server return
<div id="__next"><div><input type="checkbox"/></div></div>
.On the client side, I see
in the console, making me believe that the page was rehydrated and rendered with
ischecked
being true.Yet, the checkbox remains unchecked.
The checkbox otherwise works fine (I can check/uncheck it) and the behavior also doesn't occur when performing intra-app page navigation. The issue seems to be tied to the hydration process.
Expected Behavior
I would expect the checkbox to be checked when the page is cold-loaded via http://localhost:3000/min?a=true, despite having been rendered in the unchecked state on the server side due to the lack of query parameters available there.
To Reproduce
A self contained example is given above. Place it in the
pages
folder.The text was updated successfully, but these errors were encountered: