File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff 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
209213Then 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
212216import { useDataProvider } from ' react-admin' ;
213217import { useMutation } from ' @tanstack/react-query' ;
214218
219+ import type { MyDataProvider } from ' ./dataProvider' ;
220+
215221const BanUserButton = ({ userId }: { userId: string }) => {
216- const dataProvider = useDataProvider ();
222+ const dataProvider = useDataProvider < MyDataProvider > ();
217223 const { mutate, isPending } = useMutation ({
218224 mutationFn : () => dataProvider .banUser (userId )
219225 });
You can’t perform that action at this time.
0 commit comments