TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.19k stars 486 forks source link

fix(history): index and entries for pushState using memoryHistory could fall out of sync #1558

Closed SeanCassiere closed 2 weeks ago

SeanCassiere commented 2 weeks ago

This change only affects memory history.

When using the history.back, it decrements the index by -1.

This is correct, since calling history.forward would require the index to be incremented by +1 and would require an entries value to be present.

However, this then causes a scenario where calling history.pushState would cause the entries array to have an extra item with the index lagging behind by one.

This change affects the history.pushState, whereby assigns the index a number based on entries.length - 1 or 0.

Fixes #1555

nx-cloud[bot] commented 2 weeks ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 90e20fb9f3a3741903e650952631bda30bff0958. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets - [`nx affected --targets=test:format,test:eslint,test:unit,test:build,build --parallel=3`](https://cloud.nx.app/runs/UpCXQy9k3q?utm_source=pull-request&utm_medium=comment) - [`nx affected --target=test:types --exclude=examples/**`](https://cloud.nx.app/runs/OUGkYPbpCM?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.