useRef

The useRef hook creates a mutable reference that persists across renders without triggering re-renders when its value changes, making it ideal for storing values that need to survive re-renders without affecting the component's rendering cycle.

It's more commonly used to store references to DOM elements, but I've also seen used as a sort of memo for accessing large JSON maps

Example:

function Component({value}) {
  const prevValueRef = useRef();
  
  useEffect(() => {
    // Store current value for next render
    prevValueRef.current = value;
  }, [value]);
  
  const prevValue = prevValueRef.current;
  return <div>Previous: {prevValue}, Current: {value}</div>;
}

Connections:

Sources: