-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I came from a standard useState hook and my code was working properly.
Now, I can't update my state (the custom_filters object) with the SetFilters method below
const initialState = {
custom_filters: {
blue: false,
green: false,
pink: false
}
}
const [filters, setFilters, deleteFilters] = useStore('custom_filters');
const CustomSwitch = (props) => {
const paramId = props.id;
const paramValue = filters[paramId];
return(
<Switch
value={paramValue}
onValueChange={value => {
setFilters(prevState => ({ ...prevState, [paramId]: value }));
}}
/>
)
}
{...}
<CustomSwitch id="blue" />
This is working : setFilters({[paramId]: value }); but I need to keep all my items inside custom_filters.
There is something wrong with my code?
Thank you for your help
Metadata
Metadata
Assignees
Labels
No labels