From e6083f8817e04bbd318fa20bfbeceebc50a25a28 Mon Sep 17 00:00:00 2001 From: Gildas Garcia Date: Thu, 13 Jun 2019 09:37:25 +0200 Subject: [PATCH] Ensure children is required on controllers --- packages/ra-core/src/controller/CreateController.tsx | 6 +----- packages/ra-core/src/controller/EditController.tsx | 6 +----- packages/ra-core/src/controller/ListController.tsx | 2 +- packages/ra-core/src/controller/ShowController.tsx | 6 ++---- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/ra-core/src/controller/CreateController.tsx b/packages/ra-core/src/controller/CreateController.tsx index 51cc59d58d6..248a35f7d9c 100644 --- a/packages/ra-core/src/controller/CreateController.tsx +++ b/packages/ra-core/src/controller/CreateController.tsx @@ -80,7 +80,7 @@ interface Props { const CreateController = (props: Props) => { useCheckMinimumRequiredProps( 'Create', - ['basePath', 'location', 'resource'], + ['basePath', 'location', 'resource', 'children'], props ); const { @@ -107,10 +107,6 @@ const CreateController = (props: Props) => { [resource, basePath] // eslint-disable-line react-hooks/exhaustive-deps ); - if (!children) { - return null; - } - const resourceName = translate(`resources.${resource}.name`, { smart_count: 1, _: inflection.humanize(inflection.singularize(resource)), diff --git a/packages/ra-core/src/controller/EditController.tsx b/packages/ra-core/src/controller/EditController.tsx index b91e2c5c3c9..5f6fa7d013e 100644 --- a/packages/ra-core/src/controller/EditController.tsx +++ b/packages/ra-core/src/controller/EditController.tsx @@ -81,7 +81,7 @@ interface Props { * export default App; */ const EditController = (props: Props) => { - useCheckMinimumRequiredProps('Edit', ['basePath', 'resource'], props); + useCheckMinimumRequiredProps('Edit', ['basePath', 'resource', 'children'], props); const { basePath, children, id, resource, undoable } = props; const translate = useTranslate(); const dispatch = useDispatch(); @@ -133,10 +133,6 @@ const EditController = (props: Props) => { [resource, id, record, basePath, undoable] // eslint-disable-line react-hooks/exhaustive-deps ); - if (!children) { - return null; - } - return children({ isLoading: loading, defaultTitle, diff --git a/packages/ra-core/src/controller/ListController.tsx b/packages/ra-core/src/controller/ListController.tsx index 19676aa0d81..76ca0480e82 100644 --- a/packages/ra-core/src/controller/ListController.tsx +++ b/packages/ra-core/src/controller/ListController.tsx @@ -113,7 +113,7 @@ const defaultSort = { const ListController = (props: Props) => { useCheckMinimumRequiredProps( 'List', - ['basePath', 'location', 'resource'], + ['basePath', 'location', 'resource', 'children'], props ); if (props.filter && isValidElement(props.filter)) { diff --git a/packages/ra-core/src/controller/ShowController.tsx b/packages/ra-core/src/controller/ShowController.tsx index 19d3dd7c5fb..bdbda6682db 100644 --- a/packages/ra-core/src/controller/ShowController.tsx +++ b/packages/ra-core/src/controller/ShowController.tsx @@ -71,7 +71,7 @@ interface Props { * export default App; */ const ShowController = (props: Props) => { - useCheckMinimumRequiredProps('Show', ['basePath', 'resource'], props); + useCheckMinimumRequiredProps('Show', ['basePath', 'resource', 'children'], props); const { basePath, children, id, resource } = props; const translate = useTranslate(); const version = useVersion(); @@ -96,9 +96,7 @@ const ShowController = (props: Props) => { id, record, }); - if (!children) { - return null; - } + return children({ isLoading: loading, defaultTitle,