Skip to content

Commit

Permalink
Fix compilation errors in List
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Apr 9, 2024
1 parent e9b4b6c commit 75ee4b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/ra-ui-materialui/src/list/Count.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export const Count = (props: CountProps) => {
...rest
} = props;
const resource = useResourceContext(props);
if (!resource) {
throw new Error(
'The Count component must be used inside a ResourceContext or must be passed a resource prop.'
);
}
const oneSecondHasPassed = useTimeout(timeout);
const createPath = useCreatePath();

Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/list/Empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Empty = (props: EmptyProps) => {
const getResourceLabel = useGetResourceLabel();
const resourceName = translate(`resources.${resource}.forcedCaseName`, {
smart_count: 0,
_: getResourceLabel(resource, 0),
_: resource ? getResourceLabel(resource, 0) : undefined,
});

const emptyMessage = translate('ra.page.empty', { name: resourceName });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const DatagridLoading = ({
nbChildren,
nbFakeLines = 5,
size,
}: DatagridLoadingProps): JSX.Element => {
}: DatagridLoadingProps) => {
const oneSecondHasPassed = useTimeout(1000);

return oneSecondHasPassed ? (
if (!oneSecondHasPassed) return null;
return (
<div className={DatagridClasses.root}>
<Table
className={clsx(DatagridClasses.table, className)}
Expand Down Expand Up @@ -113,7 +113,7 @@ const DatagridLoading = ({
</TableBody>
</Table>
</div>
) : null;
);
};

DatagridLoading.propTypes = {
Expand Down

0 comments on commit 75ee4b6

Please sign in to comment.