Feature/move list to client (#50)
This commit is contained in:
committed by
GitHub
parent
c2abdaadf2
commit
668434d246
@@ -1,6 +1,8 @@
|
||||
import { useTransition } from 'react';
|
||||
import { parseAsInteger, useQueryState } from 'nuqs';
|
||||
|
||||
import { useDebounceValue } from './useDebounceValue';
|
||||
|
||||
export function useCursor() {
|
||||
const [loading, startTransition] = useTransition();
|
||||
const [cursor, setCursor] = useQueryState(
|
||||
@@ -15,3 +17,18 @@ export function useCursor() {
|
||||
loading,
|
||||
};
|
||||
}
|
||||
|
||||
export type UseDebouncedCursor = ReturnType<typeof useDebouncedCursor>;
|
||||
|
||||
export function useDebouncedCursor() {
|
||||
const [cursor, setCursor] = useQueryState(
|
||||
'cursor',
|
||||
parseAsInteger.withDefault(0)
|
||||
);
|
||||
const debouncedCursor = useDebounceValue(cursor, 200);
|
||||
return {
|
||||
value: cursor,
|
||||
set: setCursor,
|
||||
debounced: debouncedCursor,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user