UNPKG

next

Version:

The React Framework

25 lines (24 loc) • 1.05 kB
// In the browser, React keys include concrete params so navigation preserves // or resets component state according to the segment's actual identity. export { createRouterCacheKey as createSegmentKey } from './create-router-cache-key'; // The head's key also includes the search params. Otherwise, inside a // transition, `useDeferredValue` returns the new (still pending) head instead // of the prefetched one, and the whole navigation suspends. export function createHeadKey(varyPath) { // Encode the parts as a JSON array rather than joining them. A catch-all // value and a search string can both contain `/`, so joined strings from // different params could be the same. const parts = [ varyPath.value ]; let params = varyPath.parent; while(params !== null){ const value = params.value; if (typeof value === 'string') { parts.push(value); } params = params.parent; } return JSON.stringify(parts); } //# sourceMappingURL=create-segment-key.browser.js.map