Reputation: 362
Testing the following piece of code with Redux Form 7.4.0:
<Field
name="employed"
id="employed"
component="input"
type="checkbox"
onChange={e => console.log(e.target.value)}
/>
What seems strange to me is that when I click the checkbox for the first time I can see that e.target.value
is an emty string. When I click the checkbox for the second time e.target.value
is true
but I can see that the checkbox is unchecked. When I click I click the checkbox for the third time e.target.value
is false
but I can see that the checkbox is checked. This behavior seems to me incorrect end different from behavior of
<Field
name="lastName"
component="input"
type="text"
placeholder="Last Name"
onChange={e => console.log(e.target.value)}
/>
for which e.target.value
is the same as the current value visible in the input field.
Can someone clarify this different behavior? Is it an issue of React Form?
I'm using Redux Form oficial example for testing https://codesandbox.io/s/mZRjw05yp
Upvotes: 0
Views: 1040
Reputation: 11800
The checkbox value is not like an input
, the value of the checkbox is inside e.target.checked
Upvotes: 2