React DatePicker Popover无法打开

时间:2017-04-26 16:13:01

标签: reactjs datepicker react-datepicker

我有一个包装器React组件,它返回一个DatePicker:

import React from 'react';
import DatePicker from 'react-datepicker';
import moment from 'moment';

export default class MyDatePicker extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      startDate: moment()
    };
  }

  handleChange(date) {
    this.setState({
      startDate: date
    });
  }

  render() {
    return <DatePicker
        selected={this.state.startDate}
        onChange={this.handleChange.bind(this)}
        />;
  }
}

最终会更复杂,但现在它只返回DatePicker。问题是,当我尝试使用此组件时,会按预期显示预填充日期字段,但是当我单击该字段时,日历弹出窗口不会打开。我需要做些什么才能打开日历弹出窗口?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

导入'react-datepicker/dist/react-datepicker.css''react-datepicker/dist/react-datepicker-cssmodules.css'