useEffect will execute the function when there was re-render occurs and when the state value is changed. The useMemo also work similar like useEffect where it Will execute the function when there was re-render occurs and when the state value was change.
But what is the different between this two hook(useMemo and useEffect)
useEffect
is for executing code anduseMemo
is for caching a value. Check examples of each and Google some basic articles covering core React hooks