Skip to content

Commit f0013de

Browse files
authoredNov 4, 2020
Merge pull request #5481 from marmelab/fix-withDataProvider-without-options
Fix error when using withDataProvider without options argument
2 parents 5076d5a + d6b7ba5 commit f0013de

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎packages/ra-core/src/dataProvider/useDataProviderWithDeclarativeSideEffects.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const useDataProviderWithDeclarativeSideEffects = (): DataProviderProxy => {
3535
let finalAllArguments = allArguments;
3636

3737
if (
38+
options &&
3839
Object.keys(options).some(key =>
3940
['onSuccess', 'onFailure'].includes(key)
4041
)

‎packages/ra-core/src/dataProvider/withDataProvider.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { DataProvider } from '../types';
33

4-
import useDataProvider from './useDataProviderWithDeclarativeSideEffects';
4+
import useDataProviderWithDeclarativeSideEffects from './useDataProviderWithDeclarativeSideEffects';
55

66
export interface DataProviderProps {
77
dataProvider: DataProvider;
@@ -58,7 +58,10 @@ export interface DataProviderProps {
5858
const withDataProvider = <P extends object>(
5959
Component: React.ComponentType<P>
6060
): React.FunctionComponent<P & DataProviderProps> => (props: P) => (
61-
<Component {...props} dataProvider={useDataProvider()} />
61+
<Component
62+
{...props}
63+
dataProvider={useDataProviderWithDeclarativeSideEffects()}
64+
/>
6265
);
6366

6467
export default withDataProvider;

0 commit comments

Comments
 (0)
Please sign in to comment.