Randa Randa - 3 months ago 19
Javascript Question

ReactJS error warning

I'm creating my first application with ReactJS and I found this warning when I run my code :

"Warning: Failed form propType: You provided a

checked
prop to a form field without an
onChange
handler. This will render a read-only field. If the field should be mutable use
defaultChecked
. Otherwise, set either
onChange
or
readOnly
. Check the render method of
Login
."

Can someone tell me how I fix it please ?

Answer

You need to add defaultChecked attribute to your checkbox:

<div>
    <input type='checkbox' defaultChecked />
</div>