Bare with me, let me explain the scenario first.

Imagine you need to do something, i.e. call a function when a state updates, easiest way in React would be to use React.useEffect and use the state as the dependency so the hook fires every time the state updates.

But according to the documentation, the dependency array should contain things i.e. functions and state being used inside the hook that are declared outside its body so that the hook has the updated dependencies it is using.

What if we don’t want the React.useEffect to be called every time the rest of…

Arbaz Ajaz

Arbaz is a MERN Stack developer, aiming to make learning programming accessible and straight forward

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store