Skip to content

Commit 68b7ed5

Browse files
committed
refactor: prefixcache
1 parent bede37c commit 68b7ed5

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

examples/components/ReactRouterExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const ReactRouterExample = (function () {
88
return function ReactRouterExample() {
99
return (
1010
<BrowserRouter>
11-
<NavigationStateProvider>
11+
<NavigationStateProvider debug>
1212
<App />
1313
</NavigationStateProvider>
1414
</BrowserRouter>

src/lib/LocationKeyedCache.js renamed to src/lib/PrefixCache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export default function LocationKeyedCache(locationId, cache) {
1+
export default function PrefixCache(prefix, cache) {
22
function makeKey(key) {
3-
return [locationId, key].filter(Boolean).join('-')
3+
return [prefix, key].filter(Boolean).join('-')
44
}
55

66
return {

src/lib/useNavigationStateCache.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useMemo } from 'react'
22

33
import GenerationalCache from '../lib/GenerationalCache'
4-
import LocationKeyedCache from '../lib/LocationKeyedCache'
4+
import PrefixCache from '../lib/PrefixCache'
55
import makeLocationId from '../lib/makeLocationId'
66
import usePrevious from '../lib/usePrevious'
77

@@ -31,8 +31,5 @@ export default function useNavigationStateCache(
3131
})
3232
}, [cache, history, prevLocationRef, historyListenLocationAccessor])
3333

34-
return useMemo(() => new LocationKeyedCache(locationId, cache), [
35-
locationId,
36-
cache,
37-
])
34+
return useMemo(() => new PrefixCache(locationId, cache), [locationId, cache])
3835
}

0 commit comments

Comments
 (0)