Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

The validation message never appears under an MUI X Date Picker

ErrorhelperText is set on DatePicker but nothing renders under the field

Short answer

A DatePicker does not take helperText or error as direct props. They belong to its inner TextField, so you pass them through slotProps.textField. With react-hook-form, wrap the picker in a Controller and feed error and helperText from fieldState, otherwise the form state never reaches the field.

  • Applies to MUI X Date Pickers v7, @mui/material 6, react-hook-form 7, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check how your picker is registered. If it uses register() or has helperText as a direct prop, one of the causes below applies. Search the file for both.

    grep -n "helperText\|renderInput\|register(" src/components/*.tsx
  2. 2Match what you see, then jump to its fix

    1. 1The picker renders, but no text appears below it, even with a hard-coded stringhelperText is a direct prop of DatePickerFix
    2. 2Props passed to renderInput are ignoredrenderInput was used, and it was removedFix
    3. 3The helper text works when hard-coded, but the validation message from the form never showsThe picker is not connected to the form stateFix

What does the error look like?

  • helperText is set on DatePicker but nothing renders under the field
  • The field never turns red after a failed validation
  • Passing renderInput has no effect on the picker

Cause 1 of 3

helperText is a direct prop of DatePicker

1Check

In current MUI X, extra TextField props are not accepted on the picker itself. The docs say the textField slot is where custom props for the TextField go.

grep -n "<DatePicker" -A6 src/components/*.tsx

2Fix

Move helperText into slotProps.textField.

<DatePicker
  label="Start date"
  slotProps={{ textField: { helperText: 'Please fill this field' } }}
/>

3Verify

Reload the page. The text shows under the field.

npm run dev

Confirmed by mui.com

Did this fix it?

Cause 2 of 3

renderInput was used, and it was removed

1Check

The migration guide says renderInput was replaced by slot props. A leftover renderInput from an older tutorial is therefore dead code.

grep -rn "renderInput" src/

2Fix

Delete renderInput and pass the TextField props, such as variant, through slotProps.textField.

<DatePicker
  slotProps={{ textField: { variant: 'outlined', helperText: 'Required' } }}
/>

3Verify

Run the type checker. An unknown renderInput prop would be reported if it is still there.

npx tsc --noEmit

Confirmed by mui.com

Did this fix it?

Cause 3 of 3

The picker is not connected to the form state

1Check

react-hook-form gives the error to you in fieldState inside a Controller. If the picker is not inside a Controller, there is no fieldState to read.

grep -n "Controller" src/components/*.tsx

2Fix

Wrap the picker in a Controller and pass fieldState.invalid and fieldState.error?.message to slotProps.textField. Give the rule a string message, otherwise there is no message to show.

<Controller
  name="startDate"
  control={control}
  rules={{ required: 'Start date is required' }}
  render={({ field, fieldState }) => (
    <DatePicker
      label="Start date"
      value={field.value}
      onChange={field.onChange}
      slotProps={{
        textField: {
          onBlur: field.onBlur,
          error: fieldState.invalid,
          helperText: fieldState.error?.message,
        },
      }}
    />
  )}
/>

3Verify

Submit the form with the field empty. The text field turns red and shows the message.

npm run dev

Confirmed by react-hook-form.com

Did this fix it?

How do I stop it coming back?

  • Set defaultValues for every field in useForm; an undefined starting value makes React warn about an uncontrolled field turning controlled.
  • Give each validation rule a string message so the helper text has something to show.
  • After a MUI X upgrade, read the migration guide for the picker before fixing symptoms one by one.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.