'MUI Datepicker how to disable next month only

I'm using MUI v5 and I want to disable next month only in datepicker. Others are available



Solution 1:[1]

import moment from 'moment';

const isNextMonth = (date) = {
  const startOfNextMonth = moment().add(1, 'month').startOf('month');
  const endOfNextMonth = moment().add(1, 'month').endOf('month');
  return date >= startOfNextMonth && date <= endOfNextMonth;
};

<LocalizationProvider dateAdapter={AdapterDateFns}>
  <DatePicker
    views={['year', 'month', 'day']}
    label={label}
    shouldDisableDate={isNextMonth}
    value={value}
    onChange={handleChange}
    renderInput={(params) => <TextField {...params} helperText={null} />}
  />
</LocalizationProvider>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alba Hoo