@refinedev/core 5.0.2 → 5.0.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@refinedev/core",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "private": false,
5
5
  "description": "Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.",
6
6
  "repository": {
@@ -114,6 +114,8 @@ export type UseCustomReturnType<TData, TError> = {
114
114
  };
115
115
  } & UseLoadingOvertimeReturnType;
116
116
 
117
+ const EMPTY_OBJECT = Object.freeze({}) as any;
118
+
117
119
  export const useCustom = <
118
120
  TQueryFnData extends BaseRecord = BaseRecord,
119
121
  TError extends HttpError = HttpError,
@@ -231,7 +233,7 @@ export const useCustom = <
231
233
  return {
232
234
  query: queryResponse,
233
235
  result: {
234
- data: queryResponse.data?.data || ({} as TData),
236
+ data: queryResponse.data?.data || EMPTY_OBJECT,
235
237
  },
236
238
  overtime: { elapsedTime },
237
239
  };
@@ -101,6 +101,8 @@ export type UseListReturnType<TData, TError> = {
101
101
  };
102
102
  } & UseLoadingOvertimeReturnType;
103
103
 
104
+ const EMPTY_ARRAY = Object.freeze([]) as [];
105
+
104
106
  /**
105
107
  * `useList` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving items from a `resource` with pagination, sort, and filter configurations.
106
108
  *
@@ -315,7 +317,7 @@ export const useList = <
315
317
  return {
316
318
  query: queryResponse,
317
319
  result: {
318
- data: queryResponse?.data?.data || [],
320
+ data: queryResponse?.data?.data || EMPTY_ARRAY,
319
321
  total: queryResponse?.data?.total,
320
322
  },
321
323
  overtime: { elapsedTime },
@@ -85,6 +85,8 @@ export type UseManyProps<TQueryFnData, TError, TData> = {
85
85
  LiveModeProps &
86
86
  UseLoadingOvertimeOptionsProps;
87
87
 
88
+ const EMPTY_ARRAY = Object.freeze([]) as [];
89
+
88
90
  /**
89
91
  * `useMany` is a modified version of `react-query`'s {@link https://tanstack.com/query/v5/docs/framework/react/guides/queries `useQuery`} used for retrieving multiple items from a `resource`.
90
92
  *
@@ -259,7 +261,7 @@ export const useMany = <
259
261
  return {
260
262
  query: queryResponse,
261
263
  result: {
262
- data: queryResponse?.data?.data || [],
264
+ data: queryResponse?.data?.data || EMPTY_ARRAY,
263
265
  },
264
266
  overtime: { elapsedTime },
265
267
  };
@@ -176,6 +176,7 @@ export type useTableReturnType<
176
176
 
177
177
  const defaultPermanentFilter: CrudFilter[] = [];
178
178
  const defaultPermanentSorter: CrudSort[] = [];
179
+ const EMPTY_ARRAY = Object.freeze([]) as [];
179
180
 
180
181
  export function useTable<
181
182
  TQueryFnData extends BaseRecord = BaseRecord,
@@ -434,7 +435,7 @@ export function useTable<
434
435
  createLinkForSyncWithLocation,
435
436
  overtime: queryResult.overtime,
436
437
  result: {
437
- data: queryResult.result?.data || [],
438
+ data: queryResult.result?.data || EMPTY_ARRAY,
438
439
  total: queryResult.result?.total,
439
440
  },
440
441
  };