@tanstack/react-router
Advanced tools
Comparing version 1.51.8 to 1.51.9
@@ -290,6 +290,10 @@ import { RootRouteId } from './root.js'; | ||
parentRoute: TParentRoute; | ||
id: TId; | ||
path: TPath; | ||
fullPath: TFullPath; | ||
to: TrimPathRight<TFullPath>; | ||
private _id; | ||
private _path; | ||
private _fullPath; | ||
private _to; | ||
get to(): TrimPathRight<TFullPath>; | ||
get id(): TId; | ||
get path(): TPath; | ||
get fullPath(): TFullPath; | ||
children?: TChildren; | ||
@@ -296,0 +300,0 @@ originalIndex?: number; |
@@ -61,3 +61,3 @@ import invariant from "tiny-invariant"; | ||
if (isRoot) { | ||
this.path = rootRouteId; | ||
this._path = rootRouteId; | ||
} else { | ||
@@ -85,6 +85,6 @@ invariant( | ||
const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]); | ||
this.path = path; | ||
this.id = id; | ||
this.fullPath = fullPath; | ||
this.to = fullPath; | ||
this._path = path; | ||
this._id = id; | ||
this._fullPath = fullPath; | ||
this._to = fullPath; | ||
}; | ||
@@ -136,2 +136,31 @@ this.updateLoader = (options2) => { | ||
} | ||
get to() { | ||
invariant( | ||
this._to, | ||
`trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.` | ||
); | ||
return this._to; | ||
} | ||
get id() { | ||
invariant( | ||
this._id, | ||
`trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.` | ||
); | ||
return this._id; | ||
} | ||
get path() { | ||
invariant( | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
this.isRoot || this._id || this._path, | ||
`trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.` | ||
); | ||
return this._path; | ||
} | ||
get fullPath() { | ||
invariant( | ||
this._fullPath, | ||
`trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.` | ||
); | ||
return this._fullPath; | ||
} | ||
addChildren(children) { | ||
@@ -138,0 +167,0 @@ this.children = Array.isArray(children) ? children : Object.values(children); |
{ | ||
"name": "@tanstack/react-router", | ||
"version": "1.51.8", | ||
"version": "1.51.9", | ||
"description": "Modern and scalable routing for React applications", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -882,10 +882,42 @@ import invariant from 'tiny-invariant' | ||
// Set up in this.init() | ||
// The following properties are set up in this.init() | ||
parentRoute!: TParentRoute | ||
id!: TId | ||
// customId!: TCustomId | ||
path!: TPath | ||
fullPath!: TFullPath | ||
to!: TrimPathRight<TFullPath> | ||
private _id!: TId | ||
private _path!: TPath | ||
private _fullPath!: TFullPath | ||
private _to!: TrimPathRight<TFullPath> | ||
public get to() { | ||
invariant( | ||
this._to, | ||
`trying to access property 'to' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`, | ||
) | ||
return this._to | ||
} | ||
public get id() { | ||
invariant( | ||
this._id, | ||
`trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`, | ||
) | ||
return this._id | ||
} | ||
public get path() { | ||
invariant( | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
this.isRoot || this._id || this._path, | ||
`trying to access property 'path' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`, | ||
) | ||
return this._path | ||
} | ||
public get fullPath() { | ||
invariant( | ||
this._fullPath, | ||
`trying to access property 'fullPath' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.`, | ||
) | ||
return this._fullPath | ||
} | ||
// Optional | ||
@@ -985,3 +1017,3 @@ children?: TChildren | ||
if (isRoot) { | ||
this.path = rootRouteId as TPath | ||
this._path = rootRouteId as TPath | ||
} else { | ||
@@ -1022,7 +1054,7 @@ invariant( | ||
this.path = path as TPath | ||
this.id = id as TId | ||
this._path = path as TPath | ||
this._id = id as TId | ||
// this.customId = customId as TCustomId | ||
this.fullPath = fullPath as TFullPath | ||
this.to = fullPath as TrimPathRight<TFullPath> | ||
this._fullPath = fullPath as TFullPath | ||
this._to = fullPath as TrimPathRight<TFullPath> | ||
} | ||
@@ -1029,0 +1061,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
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
1488272
18582