refactor(Pinned posts carousel): Don't animate initial resize (#34868)
This commit is contained in:
parent
7efe20337c
commit
1cc853059f
2 changed files with 28 additions and 2 deletions
16
app/javascript/mastodon/hooks/usePrevious.ts
Normal file
16
app/javascript/mastodon/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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue