How does antd DatePicker change dates dynamically?

how to change its display value dynamically?

for example, there is a button for the next day, the previous day, after clicking, you can dynamically change the display date

Apr.05,2021

use setFieldsValue with Form
Don't even think about taking out Form when you fill in the form


defaultValue

if you can't, you can try

.
value

follow the source code to see that RangePicker is bound to value, and it is really effective if you try it yourself


examples on ant design documents

import { DatePicker } from 'antd';
import moment from 'moment';

const dateFormat = 'YYYY/MM/DD';
ReactDOM.render(
  <div>
    <DatePicker defaultValue={moment('2015/01/01', dateFormat)} format={dateFormat} /> 
  </div>,
  mountNode);

just set defaultValue as a variable and click on the previous or next day to change defaultValue

Menu