clone.weekday is not a function

See original GitHub issue

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 PickerPanel)
    in div (created by PickerPanel)
    in PickerPanel (created by InnerPicker)
    in div (created by InnerPicker)
    in div (created by PopupInner)
    in PopupInner (created by Align)
    in Align (created by CSSMotion)
    in CSSMotion (created by ForwardRef)
    in ForwardRef (created by Popup)
    in div (created by Popup)
    in Popup (created by Trigger)
    in Portal (created by Trigger)
    in Trigger (created by PickerTrigger)
    in PickerTrigger (created by InnerPicker)
    in InnerPicker (created by Picker)
    in Picker (created by Context.Consumer)
    in LocaleReceiver (created by Picker)
    in Picker (at Header.tsx:35)
    in header (at Header.tsx:33)
    in div (at Header.tsx:32)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

3reactions
iMuFengcommented, Nov 17, 2020

@jstaro found a way to do this.

import dayjs from 'dayjs'
import advancedFormat from 'dayjs/plugin/advancedFormat'
import customParseFormat from 'dayjs/plugin/customParseFormat'
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)
3reactions
marian2jscommented, Oct 20, 2020

This workaround solves the issue without having to downgrade dayjs:

https://github.com/ant-design/ant-design/issues/26190#issuecomment-703673400

Those lines should be added into this library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Antd datepicker (date.clone is not a function) - Stack Overflow
I have realized that when using the inside <Form.Item > <Form.Item /> it will drop 'date.clone is not a function' error. So you...
Read more >
[Solved]-Antd datepicker (date.clone is not a function)-Reactjs
I faced with the similar issue (date.clone is not a function) when tryed to use saved as a string type data for DatePicker...
Read more >
[SOLVED] AntD Problem with DatePicker and moment.js ...
I'm trying to use AntD with a datepicker form but keep getting this error: Uncaught TypeError: config._d.getTime is not a function at new ......
Read more >
Dayjs Clone
All Day.js objects are **immutable**. Still, `dayjs#clone` can create a clone of the current object if you need one.
Read more >
antd Datepicker组件——date.clone is not a function - CSDN博客
clone is not a function或者date1.isAfter is not a function 原因分析: 在From中渲染默认值,一般数据请求拿到返回值存在异步,会晚于渲染,因此日期 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found