'How to set the global disbaledDate property for DatePicker component in React(TypeScript)?

The Questions is: How to set the global disbaledDate property for DatePicker component in React(TypeScript)? I want to set all the DatePicker component can't select the date before 9999/12/31.

I try to package the DatePicker as a React Component, but const { RangePicker } = DatePicker; doesn't work

————————————

That is the Detail of my project: First I use the DayJs to replace the Moment.js like this:

// DatePicker.tsx
import { Dayjs } from 'dayjs';
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
import generatePicker from 'antd/es/date-picker/generatePicker';
import 'antd/es/date-picker/style/index';
export const DatePicker = generatePicker<Dayjs>(dayjsGenerateConfig);

Then I use the DatePicker and RangePicker in other components like this:

// testPage.tsx
import DatePicker from '../common/DatePicker.tsx';
...
export function testPage(props: Props) {
   const { RangePicker } = DatePicker;
   return <>
             <DatePicker>
             <RangePicker>
          </>
}

So, How Can I set the global disbaledDate property for DatePicker without change any code in file testPage.tsx ?



Sources

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

Source: Stack Overflow

Solution Source