Skip to content

Commit

Permalink
Ensure children is required on controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Jun 15, 2019
1 parent a2acace commit e6083f8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
6 changes: 1 addition & 5 deletions packages/ra-core/src/controller/CreateController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ interface Props {
const CreateController = (props: Props) => {
useCheckMinimumRequiredProps(
'Create',
['basePath', 'location', 'resource'],
['basePath', 'location', 'resource', 'children'],
props
);
const {
Expand All @@ -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)),
Expand Down
6 changes: 1 addition & 5 deletions packages/ra-core/src/controller/EditController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/ListController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 2 additions & 4 deletions packages/ra-core/src/controller/ShowController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -96,9 +96,7 @@ const ShowController = (props: Props) => {
id,
record,
});
if (!children) {
return null;
}

return children({
isLoading: loading,
defaultTitle,
Expand Down

0 comments on commit e6083f8

Please sign in to comment.