@tanstack/react-router 1.4.0 → 1.4.2
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/build/cjs/RouterProvider.js +1 -1
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils.js +6 -2
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +7 -4
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +355 -355
- package/build/types/utils.d.ts +2 -1
- package/build/umd/index.development.js +7 -3
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/RouterProvider.tsx +1 -1
- package/src/utils.ts +6 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.2",
|
|
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.4.
|
|
47
|
+
"@tanstack/history": "1.4.2"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/RouterProvider.tsx
CHANGED
|
@@ -264,7 +264,7 @@ export function useRouter<
|
|
|
264
264
|
: routerContext
|
|
265
265
|
const value = React.useContext(resolvedContext)
|
|
266
266
|
warning(
|
|
267
|
-
opts?.warn && value,
|
|
267
|
+
!((opts?.warn ?? true) && !value),
|
|
268
268
|
'useRouter must be used inside a <RouterProvider> component!',
|
|
269
269
|
)
|
|
270
270
|
return value as any
|
package/src/utils.ts
CHANGED
|
@@ -141,7 +141,7 @@ export function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K> {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* This function returns `
|
|
144
|
+
* This function returns `prev` if `_next` is deeply equal.
|
|
145
145
|
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
146
146
|
* This can be used for structural sharing between immutable JSON values for example.
|
|
147
147
|
* Do not use this with signals
|
|
@@ -153,7 +153,7 @@ export function replaceEqualDeep<T>(prev: any, _next: T): T {
|
|
|
153
153
|
|
|
154
154
|
const next = _next as any
|
|
155
155
|
|
|
156
|
-
const array =
|
|
156
|
+
const array = isPlainArray(prev) && isPlainArray(next)
|
|
157
157
|
|
|
158
158
|
if (array || (isPlainObject(prev) && isPlainObject(next))) {
|
|
159
159
|
const prevSize = array ? prev.length : Object.keys(prev).length
|
|
@@ -208,6 +208,10 @@ function hasObjectPrototype(o: any) {
|
|
|
208
208
|
return Object.prototype.toString.call(o) === '[object Object]'
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
export function isPlainArray(value: unknown) {
|
|
212
|
+
return Array.isArray(value) && value.length === Object.keys(value).length
|
|
213
|
+
}
|
|
214
|
+
|
|
211
215
|
export function deepEqual(a: any, b: any, partial: boolean = false): boolean {
|
|
212
216
|
if (a === b) {
|
|
213
217
|
return true
|