Search code examples
reactjsantd

Antd datepicker unexpected behaviour


enter image description here

I use Antd and React. In my modal I am setting values of field including datepicker. So far it works ok. When I try to select new date datepicker renderes weird dates with blue backgrounds. While hovering these dates datepicker shows cosmic dates such as 05.05.2140. Only after clicking 'today' it works as expected.

I researched so much, but cant relate it anything. I assume it could be something with project fundamental stting but not sure. Let me know if you had any idea what is causing that.

here is code related to this issue

 form.setFields([
                        {
                            name: ['date'],
                            value: moment(resData?.transaction?.date)
                        }
                    ])
  <Form.Item
                                    rules={[
                                        {
                                            required: true,
                                            message: 'Məlumatı daxil edin',
                                        }
                                    ]}
                                    style={{ width: '200px', marginRight: '1%', display: 'inline-block' }}
                                    label='Tarix:'
                                    name={['date']}
                                >
                                    <DatePicker size='large' />
                                </Form.Item>

Solution

  • Muhammad Nouman Rafique is right. In antd v5> we should use dayjs not moment