I'm working with reactjs, trying to say that when the state of the checkbox changes I want to do this or that.
The issue is, I can't recover the checkbox state.
Here is my checkbox component from checkbox.jsx:
const Checkbox = ({ input, label, disabled }) => (
<div>
<Input
{...input}
id={input.name}
checked={input.value}
type="checkbox"
disabled={disabled}
/>
<Label htmlFor={input.name}>{label}</Label>
</div>
)
Here is my code for rendering the checkbox in form.jsx:
<div className="col-md-3">
<Field
name="checkboxName"
type="checkbox"
component={Checkbox}
label="checkbox name"
onChange={changeCheckboxValue(Checkbox.state.value)}
/>
</div>
my code for changeCheckboxValue in Checkbox.jsx (just printing the value passed in parameter):
export const changeCheckboxValue = (value) => {
console.log(value)
}
I precise that the form is not a class but a const.
I'm not a reactjs developer and struggle quite a lot with understanding where this error comes from.
If anyone has any hints for me I'd appreciate it.
Thanks
Aucun commentaire:
Enregistrer un commentaire