Skip to content

Commit e1d01e7

Browse files
committed
Review
1 parent 26dbd64 commit e1d01e7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/DataFetchingGuide.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ export const dataProvider = {
204204
.then(response => response.json());
205205
},
206206
}
207+
208+
export interface MyDataProvider extends DataProvider {
209+
banUser: (userId: string) => Promise<Record<string, any>>;
210+
}
207211
```
208212

209213
Then you can use react-query's `useMutation` hook to call the `dataProvider.banUser()` method:
@@ -212,8 +216,10 @@ Then you can use react-query's `useMutation` hook to call the `dataProvider.banU
212216
import { useDataProvider } from 'react-admin';
213217
import { useMutation } from '@tanstack/react-query';
214218

219+
import type { MyDataProvider } from './dataProvider';
220+
215221
const BanUserButton = ({ userId }: { userId: string }) => {
216-
const dataProvider = useDataProvider();
222+
const dataProvider = useDataProvider<MyDataProvider>();
217223
const { mutate, isPending } = useMutation({
218224
mutationFn: () => dataProvider.banUser(userId)
219225
});

0 commit comments

Comments
 (0)