Björn Mayer
05/31/2020, 2:45 PMchecked = state.active == true
I do have a custom onChange
handler, which sets the state:
val target = event.target as HTMLInputElement
setState {
active = target.checked
}
When checking the checkbox, react throws this message:
react_devtools_backend.js:6 Warning: A component is changing an uncontrolled input of type checkbox to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: <https://fb.me/react-controlled-components>
turansky
05/31/2020, 2:55 PMval target = event.target as HTMLInputElement
val newActive = target.checked
setState {
active = newActive
}
Björn Mayer
05/31/2020, 3:04 PMactive
to true, when initialising:
override fun State.init(props: Props) {
active = true
}
And then the message appears, without me doing any click. Refreshing the page is enoughBjörn Mayer
05/31/2020, 3:12 PMdefaultValue
and value
.
There is also defaultChecked
.
When I change my code to:
defaultChecked = state.active == true
the error disappears.
Seen here: https://github.com/facebook/react/issues/6779#issuecomment-223818616spand
06/02/2020, 9:47 AM