Skip to content

Commit

Permalink
fix(react-router): disable route properties check until HMR bug is fi…
Browse files Browse the repository at this point in the history
…xed (#2240)
  • Loading branch information
schiller-manuel committed Sep 1, 2024
1 parent 01d5efd commit 1e64284
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions packages/react-router/src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,35 +887,35 @@ export class Route<
private _to!: TrimPathRight<TFullPath>

public get to() {
invariant(
/* 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(
/* 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(
/* 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(
/* 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
}

Expand Down
3 changes: 2 additions & 1 deletion packages/react-router/tests/route.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useNavigate,
} from '../src'
import React from 'react'
import exp from 'constants'

describe('getRouteApi', () => {
it('should have the useMatch hook', () => {
Expand Down Expand Up @@ -60,6 +59,7 @@ describe('createRoute has the same hooks as getRouteApi', () => {
)
})

/* disabled until HMR bug is fixed
describe('throws invariant exception when trying to access properties before `createRouter` completed', () => {
function setup() {
const rootRoute = createRootRoute()
Expand Down Expand Up @@ -138,3 +138,4 @@ describe('throws invariant exception when trying to access properties before `cr
expect(postsRoute.to).toBe('/posts')
})
})
*/

0 comments on commit 1e64284

Please sign in to comment.