I'm not entirely clear why we need to include all* dependencies for useEffect
For example
import { apiCall } from 'api';
const App = () => {
useEffect(() => {
apiCall();
}, [])
return <p>hi</p>
}
As I understand it, this is wrong. I should include apiCall
in the dependency array. I'm just not quite clear why that's necessary? I only want this to run once, when the component mounts. Why do I need to include any other information?