Skip to content

Commit

Permalink
use UseDataProviderOptions when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Hervieu committed Feb 3, 2021
1 parent a650c28 commit 007ab09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
10 changes: 2 additions & 8 deletions packages/ra-core/src/dataProvider/useGetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ import {
Identifier,
Record,
RecordMap,
UseDataProviderOptions,
} from '../types';
import useQueryWithStore from './useQueryWithStore';

interface UseGetListOptions {
onSuccess?: (args?: any) => void;
onFailure?: (error: any) => void;
enabled?: boolean;
[key: string]: any;
}

const defaultIds = [];
const defaultData = {};

Expand Down Expand Up @@ -67,7 +61,7 @@ const useGetList = <RecordType extends Record = Record>(
pagination: PaginationPayload,
sort: SortPayload,
filter: object,
options?: UseGetListOptions
options?: UseDataProviderOptions
): {
data?: RecordMap<RecordType>;
ids?: Identifier[];
Expand Down
16 changes: 7 additions & 9 deletions packages/ra-core/src/dataProvider/useGetOne.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import get from 'lodash/get';

import { Identifier, Record, ReduxState } from '../types';
import {
Identifier,
Record,
ReduxState,
UseDataProviderOptions,
} from '../types';
import useQueryWithStore from './useQueryWithStore';

interface UseGetOneOptions {
onSuccess?: (args?: any) => void;
onFailure?: (error: any) => void;
enabled?: boolean;
[key: string]: any;
}

/**
* Call the dataProvider.getOne() method and return the resolved value
* as well as the loading state.
Expand Down Expand Up @@ -46,7 +44,7 @@ interface UseGetOneOptions {
const useGetOne = <RecordType extends Record = Record>(
resource: string,
id: Identifier,
options?: UseGetOneOptions
options?: UseDataProviderOptions
): UseGetOneHookValue<RecordType> =>
useQueryWithStore(
{ type: 'getOne', resource, payload: { id } },
Expand Down

0 comments on commit 007ab09

Please sign in to comment.