2
0

refactor(Pinned posts carousel): Don't animate initial resize (#34868)

This commit is contained in:
diondiondion
2025-05-30 20:06:41 +02:00
committed by GitHub
parent 7efe20337c
commit 1cc853059f
2 changed files with 28 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
import { useRef, useEffect } from 'react';
/**
* Returns the previous state of the passed in value.
* On first render, undefined is returned.
*/
export function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>();
useEffect(() => {
ref.current = value;
}, [value]);
return ref.current;
}