@tanstack/history
Advanced tools
Comparing version 1.61.0 to 1.61.1
@@ -217,6 +217,4 @@ const pushStateEvent = "pushstate"; | ||
let index = opts.initialIndex ?? entries.length - 1; | ||
let currentState = { | ||
key: createRandomKey() | ||
}; | ||
const getLocation = () => parseHref(entries[index], currentState); | ||
const states = entries.map(() => ({})); | ||
const getLocation = () => parseHref(entries[index], states[index]); | ||
return createHistory({ | ||
@@ -226,6 +224,7 @@ getLocation, | ||
pushState: (path, state) => { | ||
currentState = state; | ||
if (index < entries.length - 1) { | ||
entries.splice(index + 1); | ||
states.splice(index + 1); | ||
} | ||
states.push(state); | ||
entries.push(path); | ||
@@ -235,15 +234,12 @@ index = Math.max(entries.length - 1, 0); | ||
replaceState: (path, state) => { | ||
currentState = state; | ||
states[index] = state; | ||
entries[index] = path; | ||
}, | ||
back: () => { | ||
currentState = assignKey(currentState); | ||
index = Math.max(index - 1, 0); | ||
}, | ||
forward: () => { | ||
currentState = assignKey(currentState); | ||
index = Math.min(index + 1, entries.length - 1); | ||
}, | ||
go: (n) => { | ||
currentState = assignKey(currentState); | ||
index = Math.min(Math.max(index + n, 0), entries.length - 1); | ||
@@ -250,0 +246,0 @@ }, |
{ | ||
"name": "@tanstack/history", | ||
"version": "1.61.0", | ||
"version": "1.61.1", | ||
"description": "Modern and scalable routing for React applications", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -369,7 +369,5 @@ // While the public API was clearly inspired by the "history" npm package, | ||
let index = opts.initialIndex ?? entries.length - 1 | ||
let currentState = { | ||
key: createRandomKey(), | ||
} as HistoryState | ||
const states = entries.map(() => ({}) as HistoryState) | ||
const getLocation = () => parseHref(entries[index]!, currentState) | ||
const getLocation = () => parseHref(entries[index]!, states[index]) | ||
@@ -380,7 +378,8 @@ return createHistory({ | ||
pushState: (path, state) => { | ||
currentState = state | ||
// Removes all subsequent entries after the current index to start a new branch | ||
if (index < entries.length - 1) { | ||
entries.splice(index + 1) | ||
states.splice(index + 1) | ||
} | ||
states.push(state) | ||
entries.push(path) | ||
@@ -390,15 +389,12 @@ index = Math.max(entries.length - 1, 0) | ||
replaceState: (path, state) => { | ||
currentState = state | ||
states[index] = state | ||
entries[index] = path | ||
}, | ||
back: () => { | ||
currentState = assignKey(currentState) | ||
index = Math.max(index - 1, 0) | ||
}, | ||
forward: () => { | ||
currentState = assignKey(currentState) | ||
index = Math.min(index + 1, entries.length - 1) | ||
}, | ||
go: (n) => { | ||
currentState = assignKey(currentState) | ||
index = Math.min(Math.max(index + n, 0), entries.length - 1) | ||
@@ -405,0 +401,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72613
1004