I need to pass foo in the arguments of useEffect so that it can use the existing array values. So I set the new values in this array but when I went to set the value, it'll call f() function again from the userEffect. How do I get out this infinit loop?
Imaginary code example goes something like this:
const [foo, setFoo] = useState<MyType>(...);const f = () => { const baa = {...foo}; for(...) { foo.arr[x] = y; } setFoo(foo);}useEffect(() => { f(); g(); // ...}, [foo]);