Re Render default radio checked

React gives the following example of handling default values of inputs, specifically on radio buttons. https://react.dev/reference/react-dom/components/input#displaying-inputs-of-different-types. For some reason, when I implement this the re render on refresh does not render correctly. The value is set correctly, but the render looks like it sets it, then unsets it. Has anyone experienced this before? I will note, that when I change the name of the inputs, it doesn't do this, but instead rendes the default value correctly. The below would set it correctly.
<label><input type="radio" name="myRadio1" value="option1" /> Option 1</label? <label><input type="radio" name="myRadio2" value="option2" defaultChecked={true} /> Option 2</label>
<label><input type="radio" name="myRadio2" value="option3" /> Option 3</label>
<label><input type="radio" name="myRadio1" value="option1" /> Option 1</label? <label><input type="radio" name="myRadio2" value="option2" defaultChecked={true} /> Option 2</label>
<label><input type="radio" name="myRadio2" value="option3" /> Option 3</label>
but I need the name to be the same so that they can only select 1 option out of the 3.
– React
The library for web and native user interfaces
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server