const inputRef = useRef(null); attach it with ref={inputRef}, then use inputRef.current to reach the DOM element (e.g. to focus it). A ref can also store a value that does not trigger re-renders.
useMemo
useMemo(() => expensiveCalc(a), [a]) remembers a calculated value and only recalculates when its dependencies change.
💡 Key Takeaways: React useRef & useMemo
Mastering React useRef & useMemo helps you write clean and reliable React code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.