Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用反应日期http://airbnb.io/react-dates_Reactjs_Npm - Fatal编程技术网

Reactjs 使用反应日期http://airbnb.io/react-dates

Reactjs 使用反应日期http://airbnb.io/react-dates,reactjs,npm,Reactjs,Npm,我使用这个npm 我也是 import { SingleDatePicker } from 'react-dates'; and in my render function I do <SingleDatePicker id="date" /> 从'react dates'导入{SingleDatePicker}; 在我的渲染函数中,我做到了 …就是这样,而且成功了。我试图将SingleDatePicker更改为第二个API,根据文档,它是DateRangePicker。我可以

我使用这个npm

我也是

import { SingleDatePicker } from 'react-dates';
and in my render function I do

<SingleDatePicker id="date" />
从'react dates'导入{SingleDatePicker};
在我的渲染函数中,我做到了
…就是这样,而且成功了。我试图将SingleDatePicker更改为第二个API,根据文档,它是
DateRangePicker
。我可以看到它被渲染了,但当我单击它时,它什么也不做。我不知道出了什么问题,我的控制台中没有错误。

列出了
SingleDatePicker
组件所需的道具及其类型:

<SingleDatePicker
  date={this.state.date} // momentPropTypes.momentObj or null
  onDateChange={date => this.setState({ date })} // PropTypes.func.isRequired
  focused={this.state.focused} // PropTypes.bool
  onFocusChange={({ focused }) => this.setState({ focused })} // PropTypes.func.isRequired
/>
this.setState({date})//PropTypes.func.isRequired
聚焦={this.state.focused}//PropTypes.bool
onFocusChange={({focused})=>this.setState({focused}}//PropTypes.func.isRequired
/>
要处理用户交互,必须为onFocusChanged提供函数,为聚焦道具提供bool(如上所示)。使用上面的实现,您只需要向您的状态添加一个inital
focused

例如,
state={……聚焦:false}


请注意,您需要使用包将日期对象生成到
date
prop。

您确定从“react dates”导入了DateRangePicker吗?@squGEIm非常确定,因为正如我所说的,SingleDatePicker可以工作。