Skip to content

Commit 26dbd64

Browse files
committed
Review
1 parent c24618f commit 26dbd64

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

docs/CRUD.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Here, the `<List>` component will call `dataProvider.getList('posts')` to fetch
5353

5454
## Page Context
5555

56-
`<List>` and other page component don't just fetch data; they provide a way to update the page settings:
56+
`<List>` and other page components don't just fetch data; they provide a way to update the page settings:
5757

5858
- Sort field and order
5959
- Current page & page size
@@ -123,10 +123,12 @@ This is the equivalent of the following react-router configuration:
123123

124124
```jsx
125125
<ResourceContextProvider value="posts">
126-
<Route path="/posts" element={<PostList />} />
127-
<Route path="/posts/:id/show" element={<PostShow />} />
128-
<Route path="/posts/:id" element={<PostEdit />} />
129-
<Route path="/posts/create" element={<PostCreate />} />
126+
<Routes>
127+
<Route path="/posts" element={<PostList />} />
128+
<Route path="/posts/:id/show" element={<PostShow />} />
129+
<Route path="/posts/:id" element={<PostEdit />} />
130+
<Route path="/posts/create" element={<PostCreate />} />
131+
</Routes>
130132
</ResourceContextProvider>
131133
```
132134

docs/DataFetchingGuide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ POST /api/user/123/ban
192192

193193
The react-admin way to expose these endpoints to the app components is to add a custom method in the `dataProvider`:
194194

195-
```jsx
195+
```tsx
196196
import simpleRestDataProvider from 'ra-data-simple-rest';
197197

198198
const baseDataProvider = simpleRestDataProvider('http://path.to.my.api/');
199199

200200
export const dataProvider = {
201201
...baseDataProvider,
202-
banUser: (userId) => {
202+
banUser: (userId: string) => {
203203
return fetch(`/api/user/${userId}/ban`, { method: 'POST' })
204204
.then(response => response.json());
205205
},
@@ -208,11 +208,11 @@ export const dataProvider = {
208208

209209
Then you can use react-query's `useMutation` hook to call the `dataProvider.banUser()` method:
210210

211-
```jsx
211+
```tsx
212212
import { useDataProvider } from 'react-admin';
213213
import { useMutation } from '@tanstack/react-query';
214214

215-
const BanUserButton = ({ userId }) => {
215+
const BanUserButton = ({ userId }: { userId: string }) => {
216216
const dataProvider = useDataProvider();
217217
const { mutate, isPending } = useMutation({
218218
mutationFn: () => dataProvider.banUser(userId)

0 commit comments

Comments
 (0)