Anas Shad
Anas Shad

Reputation: 179

React: How to uncheck all radio inputs initially

I have this issue. I'm creating a survey with MERN stack that downloads the data from the server and displays questions and stores the answers on the server. My issue is that some questions have options checked initially. I have checked everything and does not know what's causing these to check. So, I want to uncheck all options (radio and checkboxes) initially when the parent component mounts. When I use 'checked=true', then I cannot change it afterwards.

Upvotes: 0

Views: 261

Answers (1)

ThatBrianDude
ThatBrianDude

Reputation: 3190

You can use defaultChecked

<input type="checkbox" defaultChecked={false} ... />

Upvotes: 2

Related Questions