const [filters,filtersSetter]=useState({});
function setNewSearchQuery(param,value) {
filtersSetter(preval=>({...preval,[param]:value}))
}
In my useState
, if i want to keep everything in preval
except for one key in my JSON object what do i do?
i want to remove the key and its value basically, all in one line as opposed to breaking down the object first then applying changes. That is how we update the current state, is there a way to remove one from it?
example
filters={ username="sample" , role="roleSample"}
when given username
i want to be left with
filters={ role="roleSample"}