setting react state with produce immer
//Initialising State
const [filters, setFilters] = useState({});
//Setting State
setFilters((filters) => (
produce(filters, draftFilters => {
if (param[0] === 'page') {
draftFilters.page = parseInt(param[1], 10)
}
if (param[0] === 'per_page') {
draftFilters.perPage = parseInt(param[1], 10)
}
})
));