score:1

Accepted answer
const defaultIllnesses = {asthma: "off",  infectiousDisease: "off",...};

function myComp () {
  const [values, setValues] = useState(defaultIllnesses);

  useEffect(() => {
    getDoH().then(
      (response) => {
        const valueArray = Object.entries(defaultIllnesses)
   ...
  }, [defaultIllnesses]); // this const is still a dependency, but it won't change 
  

score:1

useEffect(() => {
  setValues((state) => generateNewStateFromPrev(state));
}, []);

Related Query

More Query from same tag