53 - Useref Mutable
53 - Useref Mutable
useRef Hook
REACT
PRESENTER: MOHAMMAD ADIL
Pre-Requisites REACT
• useState
• useEffect
• useRef
Humble Request REACT
Techno Verse YT
Heavenly Delicious
useRef Hook REACT
• 2. It can be used to store a mutable value that does not cause a re-
render when updated.
• The useRef Hook allows you to persist values between renders.
• The useRef Hook is a function that returns a mutable ref object whose
.current property is initialized with the passed argument
(initialValue).
• The returned object will persist for the full lifetime of the
component.
Does Not Cause Re-renders REACT
• If we tried to count how many times our application renders using the
useState Hook, we would be caught in an infinite loop since this Hook
itself causes a re-render.
• To avoid this, we can use the useRef Hook.
useRef Hook REACT