marmelab/react-admin · error · Error

<DateField> cannot have showTime and showDate false at the s

Error message

<DateField> cannot have showTime and showDate false at the same time

What it means

<DateField> formats dates using two independent toggles: `showDate` (render the date part) and `showTime` (render the time part). If both are false, nothing would be rendered, so the field throws to flag the invalid configuration instead of silently producing an empty output.

Source

Thrown at packages/ra-ui-materialui/src/field/DateField.tsx:60

    const props = useThemeProps({
        props: inProps,
        name: PREFIX,
    });

    const {
        className,
        emptyText,
        locales,
        options,
        showTime = false,
        showDate = true,
        transform = defaultTransform,
        ...rest
    } = props;
    const translate = useTranslate();

    if (!showTime && !showDate) {
        throw new Error(
            '<DateField> cannot have showTime and showDate false at the same time'
        );
    }

    const value = useFieldValue(props);
    if (value == null || value === '') {
        return emptyText ? (
            <Typography
                component="span"
                variant="body2"
                className={className}
                {...sanitizeFieldRestProps(rest)}
            >
                {emptyText && translate(emptyText, { _: emptyText })}
            </Typography>
        ) : null;
    }

View on GitHub (pinned to 051f511bb0)

Solutions

  1. Set at least one of the props true: `<DateField source="published_at" showTime />` for time-only, or `showDate` (default true) for date-only.
  2. If you want neither rendered, remove the <DateField> instead of disabling both.
  3. Check any variables feeding showDate/showTime so both cannot be false.

Example fix

// before
<DateField source="published_at" showDate={false} showTime={false} />

// after
<DateField source="published_at" showTime />
Defensive patterns

Strategy: validation

Validate before calling

if (!showTime && !showDate) throw new Error('DateField: showTime and showDate cannot both be false');

Prevention

When it happens

Trigger: Passing both `showDate={false}` and `showTime={false}` (or showTime={false} plus a falsy showDate from a variable) to <DateField>; computing one of them from a constant/prop that is false.

Common situations: Trying to hide the date portion by setting showDate={false} and also leaving showTime={false} (the default); conditional rendering logic that disables both switches; copying a config for a time-only field but forgetting showTime={true}.

Related errors


AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30). Data as JSON: /api/errors/72f2e0f968bfaafd. Report an issue: GitHub.