@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.
@@ -25,13 +25,14 @@ export declare function last<T>(arr: T[]): T | undefined;
25
25
  export declare function functionalUpdate<TResult>(updater: Updater<TResult> | NonNullableUpdater<TResult>, previous: TResult): TResult;
26
26
  export declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
27
27
  /**
28
- * This function returns `a` if `b` is deeply equal.
28
+ * This function returns `prev` if `_next` is deeply equal.
29
29
  * If not, it will replace any deeply equal children of `b` with those of `a`.
30
30
  * This can be used for structural sharing between immutable JSON values for example.
31
31
  * Do not use this with signals
32
32
  */
33
33
  export declare function replaceEqualDeep<T>(prev: any, _next: T): T;
34
34
  export declare function isPlainObject(o: any): boolean;
35
+ export declare function isPlainArray(value: unknown): boolean;
35
36
  export declare function deepEqual(a: any, b: any, partial?: boolean): boolean;
36
37
  export declare function useStableCallback<T extends (...args: any[]) => any>(fn: T): T;
37
38
  export declare function shallow<T>(objA: T, objB: T): boolean;
@@ -797,7 +797,7 @@
797
797
  }
798
798
 
799
799
  /**
800
- * This function returns `a` if `b` is deeply equal.
800
+ * This function returns `prev` if `_next` is deeply equal.
801
801
  * If not, it will replace any deeply equal children of `b` with those of `a`.
802
802
  * This can be used for structural sharing between immutable JSON values for example.
803
803
  * Do not use this with signals
@@ -807,7 +807,7 @@
807
807
  return prev;
808
808
  }
809
809
  const next = _next;
810
- const array = Array.isArray(prev) && Array.isArray(next);
810
+ const array = isPlainArray(prev) && isPlainArray(next);
811
811
  if (array || isPlainObject(prev) && isPlainObject(next)) {
812
812
  const prevSize = array ? prev.length : Object.keys(prev).length;
813
813
  const nextItems = array ? next : Object.keys(next);
@@ -855,6 +855,9 @@
855
855
  function hasObjectPrototype(o) {
856
856
  return Object.prototype.toString.call(o) === '[object Object]';
857
857
  }
858
+ function isPlainArray(value) {
859
+ return Array.isArray(value) && value.length === Object.keys(value).length;
860
+ }
858
861
  function deepEqual(a, b, partial = false) {
859
862
  if (a === b) {
860
863
  return true;
@@ -1226,7 +1229,7 @@
1226
1229
  function useRouter(opts) {
1227
1230
  const resolvedContext = typeof document !== 'undefined' ? window.__TSR_ROUTER_CONTEXT__ || exports.routerContext : exports.routerContext;
1228
1231
  const value = React__namespace.useContext(resolvedContext);
1229
- warning(opts?.warn && value, 'useRouter must be used inside a <RouterProvider> component!');
1232
+ warning(!((opts?.warn ?? true) && !value), 'useRouter must be used inside a <RouterProvider> component!');
1230
1233
  return value;
1231
1234
  }
1232
1235
 
@@ -3441,6 +3444,7 @@
3441
3444
  exports.interpolatePath = interpolatePath;
3442
3445
  exports.invariant = invariant;
3443
3446
  exports.isDehydratedDeferred = isDehydratedDeferred;
3447
+ exports.isPlainArray = isPlainArray;
3444
3448
  exports.isPlainObject = isPlainObject;
3445
3449
  exports.isRedirect = isRedirect;
3446
3450
  exports.isServer = isServer;