concept current in category react

This is an excerpt from Manning's book React Hooks in Action.
The useRef function returns an object with a
currentproperty, as shown in figure 6.4. Every time React runs the component code, each call touseRefwill return the same ref object for that call.Figure 6.4 useRef returns an object with a current property.
![]()
The first time React invokes the component code, it assigns the initial value you pass the
useReffunction to the ref object’scurrentproperty.const ref1 = useRef("Towel"); const ref2 = useRef(42); ref1.current; // "Towel" ref2.current; // 42On subsequent renders, React assigns the same ref objects to the respective variables, based on the order of the
useRefcalls. You can persist state values by assigning them to thecurrentproperties of the refs:ref1.current = "Babel Fish"; ref2.current = "1,000,000,000,000";Assigning new values to the
currentproperties of the ref objects doesn’t trigger a re-render. But, as React always returns the same ref objects, the new values are available when the component runs again.