Feature/move list to client (#50)

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-09-01 15:02:12 +02:00
committed by GitHub
parent c2abdaadf2
commit 668434d246
181 changed files with 2922 additions and 1959 deletions

View File

@@ -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,
};
}