FixDisabledMonth.tsx 718 B

1234567891011121314151617181920212223242526
  1. import DatePicker from '../../index';
  2. import React from 'react';
  3. import { set } from 'date-fns';
  4. /**
  5. * test by cypress, don't modify this story
  6. */
  7. export default function App() {
  8. const disabledDate = (date: Date) => {
  9. const isBefore = date < set(date, { year: 2021, month: 10 });
  10. const isAfter = date > set(date, { year: 2022, month: 10 });
  11. return isBefore || isAfter;
  12. };
  13. return (
  14. <DatePicker
  15. motion={false}
  16. yearAndMonthOpts={{ motion: false }}
  17. disabledDate={disabledDate}
  18. defaultValue={new Date('2022-11')}
  19. type="month"
  20. onChange={console.log}
  21. style={{ width: 140 }}
  22. />
  23. );
  24. }