Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 27x 27x | import { create } from 'zustand';
import { DEFAULT_PAGE_KEY } from '../constants/pagination';
// Any time that usePrevNextPagination is NOT synced to location,
// store a keyed currentPage here instead
const useLocalPageStore = create(
(set) => ({
pageStore: {},
setPage: (id, page) => set((state) => {
// Any non-id keyed pages will go into a single storage slot
const key = id ?? DEFAULT_PAGE_KEY;
return { ...state, pageStore: { ...state.pageStore, [key]: page } };
}),
}),
);
export default useLocalPageStore;
|