mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-28 05:36:44 +00:00
[Glitch] refactor(Pinned posts carousel): Don't animate initial resize
Port 1cc853059f to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
16
app/javascript/flavours/glitch/hooks/usePrevious.ts
Normal file
16
app/javascript/flavours/glitch/hooks/usePrevious.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user