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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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;
}