How to Track Old State vs New State in React with useRef

In this lesson we’ll learn how to compare the differences between a value’s “old state“ vs its “new state“ inside of React. This is often important when you want to make a decision on what to do if the value has changed (and you need to see what that value was BEFORE it changed). With the standard useEffect hook in react this isn’t possible, but we can make it possible by adding in a useRef hook, so let’s dive into it! Other Important Links: --------------------------- Check out our Bootcamp: Assignment Submission App Code: Subscribe to the Channel: #react #code #learntocode #springboot #bootstrap
Back to Top