Answers for "setting react state with produce immer"

0

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)
          }
        })
      ));
Posted by: Guest on May-09-2020

Code answers related to "setting react state with produce immer"

Code answers related to "Javascript"

Browse Popular Code Answers by Language