1import { useRef } from 'react';
2
3function MyComponent() {
4 const reference = useRef(initialValue);
5 const someHandler = () => {
6 // Access reference value:
7 const value = reference.current;
8 // Update reference value:
9 reference.current = newValue; };
10
11 // ...
12}