mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix issues with search url param
This commit is contained in:
parent
d6b8ce0f49
commit
bdecaa9930
8 changed files with 256 additions and 189 deletions
17
src/hooks/usePrevious.ts
Normal file
17
src/hooks/usePrevious.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
* A hook that returns the previous value of a stateful value.
|
||||
* @param value A stateful value created by a `useState` hook.
|
||||
* @param initialValue The default value.
|
||||
* @returns The previous value.
|
||||
*/
|
||||
export function usePrevious<T>(value: T, initialValue?: T): T | undefined {
|
||||
const ref = useRef<T | undefined>(initialValue);
|
||||
|
||||
useEffect(() => {
|
||||
ref.current = value;
|
||||
});
|
||||
|
||||
return ref.current;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue