diff --git a/packages/ra-core/src/controller/field/ReferenceArrayFieldController.spec.tsx b/packages/ra-core/src/controller/field/ReferenceArrayFieldController.spec.tsx
index d114d4ec80a..5c11f5cffc9 100644
--- a/packages/ra-core/src/controller/field/ReferenceArrayFieldController.spec.tsx
+++ b/packages/ra-core/src/controller/field/ReferenceArrayFieldController.spec.tsx
@@ -7,80 +7,80 @@ import { crudGetManyAccumulate } from '../../actions';
describe('', () => {
afterEach(cleanup);
- // it('should set the loadedOnce prop to false when related records are not yet fetched', () => {
- // const children = jest.fn().mockReturnValue('child');
+ it('should set the loadedOnce prop to false when related records are not yet fetched', () => {
+ const children = jest.fn().mockReturnValue('child');
- // renderWithRedux(
- //
- // {children}
- // ,
- // {
- // admin: {
- // resources: {
- // bar: {
- // data: {},
- // },
- // },
- // },
- // }
- // );
- // expect(children.mock.calls[0][0]).toEqual({
- // currentSort: { field: 'id', order: 'ASC' },
- // loadedOnce: false,
- // referenceBasePath: '',
- // data: null,
- // ids: [1, 2],
- // });
- // });
+ renderWithRedux(
+
+ {children}
+ ,
+ {
+ admin: {
+ resources: {
+ bar: {
+ data: {},
+ },
+ },
+ },
+ }
+ );
+ expect(children.mock.calls[0][0]).toEqual({
+ currentSort: { field: 'id', order: 'ASC' },
+ loadedOnce: false,
+ referenceBasePath: '',
+ data: null,
+ ids: [1, 2],
+ });
+ });
- // it('should set the loadedOnce prop to true when at least one related record is found', () => {
- // const children = jest.fn().mockReturnValue('child');
+ it('should set the loadedOnce prop to true when at least one related record is found', () => {
+ const children = jest.fn().mockReturnValue('child');
- // renderWithRedux(
- //
- // {children}
- // ,
- // {
- // admin: {
- // resources: {
- // bar: {
- // data: {
- // 2: {
- // id: 2,
- // value: 'reference2',
- // },
- // },
- // },
- // },
- // },
- // }
- // );
+ renderWithRedux(
+
+ {children}
+ ,
+ {
+ admin: {
+ resources: {
+ bar: {
+ data: {
+ 2: {
+ id: 2,
+ value: 'reference2',
+ },
+ },
+ },
+ },
+ },
+ }
+ );
- // expect(children.mock.calls[0][0]).toEqual({
- // currentSort: { field: 'id', order: 'ASC' },
- // loadedOnce: true,
- // referenceBasePath: '',
- // data: {
- // 2: {
- // id: 2,
- // value: 'reference2',
- // },
- // },
- // ids: [1, 2],
- // });
- // });
+ expect(children.mock.calls[0][0]).toEqual({
+ currentSort: { field: 'id', order: 'ASC' },
+ loadedOnce: true,
+ referenceBasePath: '',
+ data: {
+ 2: {
+ id: 2,
+ value: 'reference2',
+ },
+ },
+ ids: [1, 2],
+ });
+ });
it('should set the data prop to the loaded data when it has been fetched', () => {
const children = jest.fn().mockReturnValue('child');
diff --git a/packages/ra-core/src/controller/field/index.ts b/packages/ra-core/src/controller/field/index.ts
index 9022a0d35e0..18f2ec85d92 100644
--- a/packages/ra-core/src/controller/field/index.ts
+++ b/packages/ra-core/src/controller/field/index.ts
@@ -2,8 +2,10 @@ import ReferenceArrayFieldController from './ReferenceArrayFieldController';
import ReferenceFieldController from './ReferenceFieldController';
import ReferenceManyFieldController from './ReferenceManyFieldController';
import useReference from './useReference';
+import useReferenceArray from './useReferenceArray';
export {
+ useReferenceArray,
ReferenceArrayFieldController,
ReferenceFieldController,
useReference,
diff --git a/packages/ra-ui-materialui/src/field/ReferenceArrayField.js b/packages/ra-ui-materialui/src/field/ReferenceArrayField.js
index 24255b44d16..0fe53768033 100644
--- a/packages/ra-ui-materialui/src/field/ReferenceArrayField.js
+++ b/packages/ra-ui-materialui/src/field/ReferenceArrayField.js
@@ -2,7 +2,7 @@ import React, { Children } from 'react';
import PropTypes from 'prop-types';
import LinearProgress from '@material-ui/core/LinearProgress';
import { withStyles, createStyles } from '@material-ui/core/styles';
-import { ReferenceArrayFieldController } from 'ra-core';
+import { useReferenceArray } from 'ra-core';
import { fieldPropTypes } from './types';
const styles = createStyles({
@@ -85,14 +85,11 @@ export const ReferenceArrayField = ({ children, ...props }) => {
}
return (
-
- {controllerProps => (
-
- )}
-
+
);
};