Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

shared-class.tsx

19 lines415 Bytes

1import { createFileRoute } from '@tanstack/react-router'
2​
3class DataStore {
4 data = new Map()
5 get(k: string) {
6 return this.data.get(k)
7 }
8 set(k: string, v: unknown) {
9 this.data.set(k, v)
10 }
12const store = new DataStore()
13​
14export const Route = createFileRoute('/store')({
15 loader: async () => {
16 store.set('items', await fetch('/api'))
17 },
18 component: () => <div>{store.get('items')}</div>,
19})