This video explores how to use refs in React. Refs are initialized with the useRef hook and they can have an initial value. The ref object has a current property that can be updated and read. The value of the ref variable is preserved between re-renders. Usually refs are used to store references to elements, control media playback or control animations, but that's not their only use. We explore two examples - focusing an input and building a stopwatch.
Contents:
0:00 Introduction
0:22 Focusing Inputs
1:18 Other Use Cases for Refs
2:08 Building a Stopwatch
3:27 Conclusion
Email: [email protected]
Twitter: / nikelaz
LinkedIn: / nikola-lazarov
#react #course