K
Size: a a a
K
K
LK
LK
export const usePrevious = <T extends {}>(value: T) => {
// The ref object is a generic container whose current property is mutable ...
// ... and can hold any value, similar to an instance property on a class
const ref = useRef<T>(null);
// Store current value in ref
useEffect(() => {
// @ts-ignore
ref.current = value;
}, [value]); // Only re-run if value changes
// Return previous value (happens before update in useEffect above)
return ref.current;
};
SS
LK
LK
LK
SS
SS
LK
LK
LK
Cannot assign to 'current' because it is a read-only property
K
LK
LK
The final argument passed to useEffect changed size between renders. The order and size of this array must remain constant
LK
const prevSelectedDate = selectedDate ? usePrevious(selectedDate) : ‘’
SS
const prevSelectedDate = selectedDate ? usePrevious(selectedDate) : ‘’
LK
SS
Cannot assign to 'current' because it is a read-only property