how to insert a object with one change in setstate react code example

Example 1: copying state to object and editing it vs setting state

//Setting State through produce

setFilters((filters) => (
       	produce(filters, draftFilters => {
            if (param[0] === 'availability') {
              draftFilters.availability = param[1]
            } else {
              draftFilters[param[0]] = parseInt(param[1], 10)
            }

//Copying to obect, then editing the object

const params = produce(filters, draftFilter => {
      draftFilter.page = page + 1;
    })
    
//In this case, we're not updating the state. Just updating the object params.

Example 2: can we add new state property using setstate in react

How to become a pro with React setState() in 10 minuteswww.freecodecamp.org › news › get-pro-with-react-set...