diff --git a/docs/List.md b/docs/List.md
index 1de2ee7ba7c..8ca5bade686 100644
--- a/docs/List.md
+++ b/docs/List.md
@@ -683,6 +683,18 @@ The `empty` component can call the `useListContext()` hook to receive the same p
- `total`,
- `version`,
+You can also set the `empty` props value to `false` to bypass the empty page display and render an empty list instead.
+
+```
+import { List } from 'react-admin';
+
+const ProductList = props => (
+
+ ...
+
+);
+```
+
### Component
By default, the List view renders the main content area inside a material-ui `` element. The actual layout of the list depends on the child component you're using (``, ``, or a custom layout component).
diff --git a/packages/ra-ui-materialui/src/list/List.spec.js b/packages/ra-ui-materialui/src/list/List.spec.js
index 45ec7688c32..23936dbf8a0 100644
--- a/packages/ra-ui-materialui/src/list/List.spec.js
+++ b/packages/ra-ui-materialui/src/list/List.spec.js
@@ -108,6 +108,26 @@ describe('
', () => {
});
});
+ it('should not render an invite when the list is empty with an empty prop set to false', async () => {
+ const Dummy = () => ;
+ const dataProvider = {
+ getList: jest.fn(() => Promise.resolve({ data: [], total: 0 })),
+ };
+ const { queryAllByText } = renderWithRedux(
+
+
+
+
+
+
+ ,
+ defaultStateForList
+ );
+ await wait(() => {
+ expect(queryAllByText('resources.posts.empty')).toHaveLength(0);
+ });
+ });
+
it('should not render an invite when a filter is active', async () => {
const Dummy = () => ;
const dataProvider = {
diff --git a/packages/ra-ui-materialui/src/list/ListView.tsx b/packages/ra-ui-materialui/src/list/ListView.tsx
index 048b52c7dd6..11c8404b80a 100644
--- a/packages/ra-ui-materialui/src/list/ListView.tsx
+++ b/packages/ra-ui-materialui/src/list/ListView.tsx
@@ -100,7 +100,7 @@ export const ListView: FC = props => {
{...sanitizeRestProps(rest)}
>
- {shouldRenderEmptyPage
+ {shouldRenderEmptyPage && empty !== false
? cloneElement(empty, listContext)
: renderList()}
diff --git a/packages/ra-ui-materialui/src/types.ts b/packages/ra-ui-materialui/src/types.ts
index 9e7560122ef..d39c29979c0 100644
--- a/packages/ra-ui-materialui/src/types.ts
+++ b/packages/ra-ui-materialui/src/types.ts
@@ -27,7 +27,7 @@ export interface ListProps extends ResourceComponentProps {
classes?: any;
className?: string;
component?: FC<{ className?: string }>;
- empty?: ReactElement;
+ empty?: ReactElement | false;
exporter?: Exporter | false;
filter?: any;
filterDefaultValues?: any;