@tanstack/react-router 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "1.2.3",
4
+ "version": "1.2.4",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -44,7 +44,7 @@
44
44
  "@tanstack/store": "^0.1.3",
45
45
  "tiny-invariant": "^1.3.1",
46
46
  "tiny-warning": "^1.0.3",
47
- "@tanstack/history": "1.2.3"
47
+ "@tanstack/history": "1.2.4"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup --config rollup.config.js"
package/src/router.ts CHANGED
@@ -259,12 +259,18 @@ export class Router<
259
259
  startReactTransition: (fn: () => void) => void = (fn) => fn()
260
260
 
261
261
  update = (newOptions: RouterConstructorOptions<TRouteTree, TDehydrated>) => {
262
+ const previousOptions = this.options
262
263
  this.options = {
263
264
  ...this.options,
264
265
  ...newOptions,
265
266
  }
266
267
 
267
- this.basepath = `/${trimPath(newOptions.basepath ?? '') ?? ''}`
268
+ if (
269
+ !this.basepath ||
270
+ (newOptions.basepath && newOptions.basepath !== previousOptions.basepath)
271
+ ) {
272
+ this.basepath = `/${trimPath(newOptions.basepath ?? '') ?? ''}`
273
+ }
268
274
 
269
275
  if (
270
276
  !this.history ||
@@ -274,7 +280,9 @@ export class Router<
274
280
  this.options.history ??
275
281
  (typeof document !== 'undefined'
276
282
  ? createBrowserHistory()
277
- : createMemoryHistory())
283
+ : createMemoryHistory({
284
+ initialEntries: [this.options.basepath || '/'],
285
+ }))
278
286
  this.latestLocation = this.parseLocation()
279
287
  }
280
288