You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs_headless/src/content/docs/data-fetching/Actions.md
+78-73Lines changed: 78 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,7 @@
1
1
---
2
-
layout: default
3
2
title: "Querying the API"
4
3
---
5
4
6
-
# Querying the API
7
-
8
5
React-admin provides special hooks to emit read and write queries to the [`dataProvider`](./DataProviders.md), which in turn sends requests to your API. Under the hood, it uses [React Query](https://tanstack.com/query/v5/) to call the `dataProvider` and cache the results.
@@ -19,7 +16,7 @@ For instance, here is how to query the Data Provider for a User record on mount,
19
16
20
17
```jsx
21
18
import { useState, useEffect } from'react';
22
-
import { useDataProvider } from'react-admin';
19
+
import { useDataProvider } from'ra-core';
23
20
import { Loading, Error } from'./MyComponents';
24
21
25
22
constUserProfile= ({ userId }) => {
@@ -75,7 +72,7 @@ const { isPending, error, data } = useGetOne(resource, { id });
75
72
For instance, here is how to fetch one User record on mount using the `useGetOne` hook:
76
73
77
74
```jsx
78
-
import { useGetOne } from'react-admin';
75
+
import { useGetOne } from'ra-core';
79
76
import { Loading, Error } from'./MyComponents';
80
77
81
78
constUserProfile= ({ userId }) => {
@@ -152,25 +149,21 @@ In addition to the `useQuery` options, react-admin query hooks also accept callb
152
149
153
150
See the [Success and Error Side Effects](#success-and-error-side-effects) below for more details.
154
151
155
-
**Tip**: In react-admin components that use the query hooks, you can override the query options using the `queryOptions` prop. For instance, to log the dataProvider calls, in the `<List>` component, you can do the following:
152
+
**Tip**: In react-admin components that use the query hooks, you can override the query options using the `queryOptions` prop. For instance, to log the dataProvider calls, in the `<ListBase>` component, you can do the following:
This could be useful when you have different shapes for a resource in lists and single record views. In those cases, you might want to avoid react-admin to prefill the cache.
@@ -505,7 +506,9 @@ Let's see how what these variables contain in a typical usage scenario:
505
506
Components use the pending state to show a loading indicator when there is no data to show. In the example above, the loading indicator is necessary for step 2, but not in step 4, because you can display the stale data while fresh data is being loaded.
Copy file name to clipboardExpand all lines: docs_headless/src/content/docs/data-fetching/DataProviderList.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,13 @@
1
1
---
2
-
layout: default
3
2
title: "Supported Data Provider Backends"
4
3
---
5
4
6
-
# Supported Data Provider Backends
5
+
Thanks to the Data Provider architecture, ra-core supports a lot of API backends. Check the list below for open-source packages developed and maintained by the core team and developers from the ra-core community.
7
6
8
-
Thanks to the Data Provider architecture, react-admin supports a lot of API backends. Check the list below for open-source packages developed and maintained by the core team and developers from the react-admin community.
9
-
10
-
If you can't find a Data Provider for your backend below, no worries! [Writing a Data Provider](./DataProviderWriting.md) takes a couple of hours, and won't prevent you from using react-admin.
7
+
If you can't find a Data Provider for your backend below, no worries! [Writing a Data Provider](./DataProviderWriting.md) takes a couple of hours, and won't prevent you from using ra-core.
0 commit comments