Open History to see the last commit
1import { createFileRoute } from '@tanstack/react-router'
2β
3const cache = new Map()
4function getCached(key: string) {
5 return cache.get(key)
6}
7function setCached(key: string, val: unknown) {
8 cache.set(key, val)
9}
10β
11export const Route = createFileRoute('/cached')({
12 loader: async () => {
13 setCached('data', await fetch('/api').then((r) => r.json()))
14 return getCached('data')
15 },
16 component: () => <div>{JSON.stringify(getCached('data'))}</div>,
17})