无法读取未定义的React材料设计的属性'date'

时间:2018-05-18 11:17:47

标签: reactjs datepicker material-design material-ui

我正在使用storybook reactJs和material-ui作为应用程序。我正在尝试从Material-ui component构建datepicker,下面是我的代码到目前为止

import React, { Fragment, PureComponent } from 'react';
import  {DatePicker}  from 'material-ui-pickers';

class DatePickers extends PureComponent {
  state = {
    selectedDate: new Date(),
  }

  render() {
    console.log(this.state);
  const  { selectedDate } = this.state;

    return (
      <div>
        <DatePicker
          label="Basic example"
          value={selectedDate}
          onChange={this.handleDateChange}
          animateYearScrolling={false}
          />
      </div>
    )
  }
}

export default DatePickers;

当我打开我的故事书时,它会显示以下错误 无法读取未定义的属性“日期”

  

TypeError:无法读取未定义的属性“date”       在DatePickerWrapper.PickerBase._this.getValidDateOrCurrent(http://localhost:6006/static/preview.bundle.js:52555:24)       在DatePickerWrapper.PickerBase(http://localhost:6006/static/preview.bundle.js:52559:19

有谁知道。这是怎么回事?

1 个答案:

答案 0 :(得分:3)

查看包含mergeInto(LibraryManager.library, { GetData: function(yourkey){ if(typeof loadData !== 'undefined'){ loadData(Pointer_stringify(yourkey)); } else { console.log("Javacript function not available..."); } }, SetData: function(yourkey, yourdata){ if(typeof saveData !== 'undefined'){ saveData(Pointer_stringify(yourkey), Pointer_stringify(yourdata)); } else { console.log("Javacript function not available..."); } } 组件代码的this working example

错误可能在以下内容中 - 您是否使用所提供的DatePicker道具将您的组件包裹在MuiPickersUtilsProvider中?

utils