@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "1.4.0",
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.0"
47
+ "@tanstack/history": "1.4.2"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup --config rollup.config.js"
@@ -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 `a` if `b` is deeply equal.
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 = Array.isArray(prev) && Array.isArray(next)
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