如何使Airbnb的“反应日期”控件最初处于关闭状态?

时间:2019-07-10 21:55:40

标签: reactjs react-dates

我有以下代码

constructor(props) {
    super(props);
    this.state = {
        startDate: null,
        endDate: null,
        focusedInput: null
    };
}

render() {
    return (
        <div>
            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/react-dates@20.2.5/lib/css/_datepicker.css" />

            <DateRangePicker
                startDate={this.state.startDate} // momentPropTypes.momentObj or null,
                startDateId="1" // PropTypes.string.isRequired,
                endDate={this.state.endDate} // momentPropTypes.momentObj or null,
                endDateId="2" // PropTypes.string.isRequired,
                onDatesChange={({ startDate, endDate }) => this.setState({ startDate, endDate })} // PropTypes.func.isRequired,
                focusedInput={this.state.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null,
                onFocusChange={focusedInput => this.setState({ focusedInput })} // PropTypes.func.isRequired,
            />
        </div>
    );
}

当转到正确的页面时,控件正在工作,但最初显示为打开状态。最初如何关闭它?

0 个答案:

没有答案