React useEffect only on Update
If you are wondering how to run React's useEffect Hook only on update , you may be surprised that you need React's useRef Hook as helper to create an instance variable for tracking the component's lifecycle. The following code shows you how to achieve it: If you want to have a reusable custom hook for it, which only triggers the effect function…