I'm working with React and I have a checkbox for the user to switch on and off at registration process.
The checkbox default value is true and when a user click's it my onchange event is calling my handler, which checks if the action.payload.value is true.
If the value is true than I'm changing the state which in turn should update the value of the checkbox (through the store).
But even though I've checked over and over and my action.payload.value === true exists the value fails to change.
here's my example:
form
<div className='form-field-wrapper'>
<input
type="checkbox"
id="attending"
value='true'
checked={props.data.attending}
onClick={props.handleChange}
/>
</div>
handler
const ACTION_HANDLERS = {
[HANDLE_CHANGE]: (state, action) => {
let newState = {}
if (action.payload.id === 'attending'){
console.log(action.payload.value) // this equals true
newState = action.payload.value === true ? {attending:false} : {attending:true}
console.log(newState) // new state never becomes false
}
};
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire