antd의 RangePicker 예제를 그대로 썼는데
clone.weekday is not a function 라는 에러가 났다.
깃허브 답변처럼 몇몇개를 더 import하니 에러가 해결됬다.
https://github.com/react-component/picker/issues/123
clone.weekday is not a function · Issue #123 · react-component/picker
dayjs <= 1.8.30 没有问题 dayjs > 1.8.30 点击日期选择器直接报错 TypeError: clone.weekday is not a function in DateBody (created by DatePanel) in div (created by DatePanel) in DatePanel (created by PickerPane...
github.com
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
// 밑에서부터 새로 추가
import advancedFormat from 'dayjs/plugin/advancedFormat'
import localeData from 'dayjs/plugin/localeData'
import weekday from 'dayjs/plugin/weekday'
import weekOfYear from 'dayjs/plugin/weekOfYear'
import weekYear from 'dayjs/plugin/weekYear'
dayjs.extend(customParseFormat)
dayjs.extend(advancedFormat)
dayjs.extend(weekday)
dayjs.extend(localeData)
dayjs.extend(weekOfYear)
dayjs.extend(weekYear)
const dateFormat = 'YYYY/MM/DD';
const {RangePicker} = DatePicker; //이 것을 꼭 해줘야 오류가 안 난다.
<RangePicker
defaultValue={[dayjs('2023/01/01', dateFormat), dayjs('2023/01/01', dateFormat)]}
onChange={startDttmOnChange}
format={dateFormat}
/>
'기타 개발' 카테고리의 다른 글
vscode에서 auto import 될 때 상대경로 말고 절대경로로 import하게 하는 설정 (1) | 2025.05.23 |
---|---|
vscode에서 auto import 처리 (0) | 2025.05.23 |
인텔리제이 환경설정 (1) | 2025.03.19 |
인텔리제이 단축키 설정하기 (0) | 2025.03.12 |
Lighthouse로 성능을 측정하여 좋은 유저 경험 만들기 (0) | 2023.11.09 |