From 04af34e76d6f7a1539e8727c10dee100a81b4580 Mon Sep 17 00:00:00 2001 From: shaoyu Date: Tue, 17 Sep 2024 14:19:38 -0700 Subject: [PATCH] fix more cases that should use ispending --- docs/List.md | 4 ++-- docs/useListController.md | 4 ++-- examples/simple/src/customRouteNoLayout.tsx | 4 ++-- .../controller/field/ReferenceFieldBase.stories.tsx | 2 +- .../controller/input/ReferenceInputBase.stories.tsx | 4 ++-- packages/ra-core/src/controller/list/useList.ts | 4 ++-- packages/ra-ui-materialui/src/list/List.spec.tsx | 12 ++++++------ packages/ra-ui-materialui/src/list/List.stories.tsx | 4 ++-- .../src/list/datagrid/Datagrid.stories.tsx | 8 ++++---- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/List.md b/docs/List.md index fd16dd7b732..28fe33dbad7 100644 --- a/docs/List.md +++ b/docs/List.md @@ -1167,8 +1167,8 @@ This is often used by APIs to return facets, aggregations, statistics, or other // }, // } const Facets = () => { - const { isLoading, error, meta } = useListContext(); - if (isLoading || error) return null; + const { isPending, error, meta } = useListContext(); + if (isPending || error) return null; return ( diff --git a/docs/useListController.md b/docs/useListController.md index c88131817a5..3f55e8b416f 100644 --- a/docs/useListController.md +++ b/docs/useListController.md @@ -270,7 +270,7 @@ import { useState } from 'react'; import { useListController } from 'react-admin'; const OfficeList = () => { - const { filterValues, setFilters, data, isLoading } = useListController({ resource: 'offices' }); + const { filterValues, setFilters, data, isPending } = useListController({ resource: 'offices' }); const [formValues, setFormValues] = useState(filterValues); const handleChange = (event) => { @@ -285,7 +285,7 @@ const OfficeList = () => { setFilters(filterFormValues); }; - if (isLoading) return
Loading...
; + if (isPending) return
Loading...
; return ( <> diff --git a/examples/simple/src/customRouteNoLayout.tsx b/examples/simple/src/customRouteNoLayout.tsx index 9ac77f11ced..9e88657d6d5 100644 --- a/examples/simple/src/customRouteNoLayout.tsx +++ b/examples/simple/src/customRouteNoLayout.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { useGetList } from 'react-admin'; const CustomRouteNoLayout = ({ title = 'Posts' }) => { - const { isLoading, total } = useGetList('posts', { + const { isPending, total } = useGetList('posts', { pagination: { page: 0, perPage: 10 }, sort: { field: 'id', order: 'ASC' }, }); @@ -10,7 +10,7 @@ const CustomRouteNoLayout = ({ title = 'Posts' }) => { return (

{title}

- {isLoading ? ( + {isPending ? (

Loading...

) : (

diff --git a/packages/ra-core/src/controller/field/ReferenceFieldBase.stories.tsx b/packages/ra-core/src/controller/field/ReferenceFieldBase.stories.tsx index afc274630a2..fc2a64f798a 100644 --- a/packages/ra-core/src/controller/field/ReferenceFieldBase.stories.tsx +++ b/packages/ra-core/src/controller/field/ReferenceFieldBase.stories.tsx @@ -354,7 +354,7 @@ export const Meta = ({ const MyReferenceField = (props: { children: React.ReactNode }) => { const context = useReferenceFieldContext(); - if (context.isLoading) { + if (context.isPending) { return

Loading...

; } diff --git a/packages/ra-core/src/controller/input/ReferenceInputBase.stories.tsx b/packages/ra-core/src/controller/input/ReferenceInputBase.stories.tsx index 5840b695253..bd9bf5b2942 100644 --- a/packages/ra-core/src/controller/input/ReferenceInputBase.stories.tsx +++ b/packages/ra-core/src/controller/input/ReferenceInputBase.stories.tsx @@ -136,7 +136,7 @@ const SelectInput = ( Partial> & ChoicesProps & { source?: string } ) => { - const { allChoices, error, isLoading, source } = useChoicesContext(props); + const { allChoices, error, isPending, source } = useChoicesContext(props); const { getChoiceValue, getChoiceText } = useChoices(props); const { field } = useInput({ ...props, source }); @@ -147,7 +147,7 @@ const SelectInput = (