Skip to content

Commit

Permalink
fix ReferenceFieldCOntroller
Browse files Browse the repository at this point in the history
  • Loading branch information
ThieryMichel committed Jul 10, 2019
1 parent d11e9ed commit 347ef96
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { FunctionComponent, ReactNode, ReactElement } from 'react';
import get from 'lodash/get';

import { Record } from '../../types';

import getResourceLinkPath, { LinkToFunctionType } from './getResourceLinkPath';
Expand All @@ -9,7 +11,6 @@ interface childrenParams extends UseReferenceProps {
}

interface Props {
id: string;
allowEmpty?: boolean;
basePath: string;
children: (params: childrenParams) => ReactNode;
Expand Down Expand Up @@ -51,11 +52,14 @@ interface Props {
*/
export const ReferenceFieldController: FunctionComponent<Props> = ({
children,
record,
source,
...props
}) => {
const id = get(record, source);
return children({
...useReference(props),
resourceLinkPath: getResourceLinkPath(props),
...useReference({ ...props, id }),
resourceLinkPath: getResourceLinkPath({ ...props, record, source }),
}) as ReactElement<any>;
};

Expand Down

0 comments on commit 347ef96

Please sign in to comment.