react-datepicker不渲染,变体错误

时间:2018-11-16 11:55:35

标签: javascript reactjs react-datepicker

我被困在问题中2至3天。 Issue

这是我的package.json文件

{
  "dependencies": {
    "autoprefixer": "^7.1.1",
    "babel-core": "^6.26.3",
    "babel-loader": "7.x",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-polyfill": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "blazy": "^1.8.2",
    "canvas-compress": "^1.1.5",
    "coffee-loader": "^0.7.3",
    "coffee-script": "^1.12.6",
    "compression-webpack-plugin": "^0.4.0",
    "css-loader": "^0.28.4",
    "extract-text-webpack-plugin": "^2.1.2",
    "file-loader": "^0.11.2",
    "file-saver": "^2.0.0-rc.3",
    "firebase": "^4.8.1",
    "glob": "^7.1.2",
    "google-libphonenumber": "^3.0.5",
    "jquery": "^3.2.1",
    "js-yaml": "^3.8.4",
    "moment": "^2.22.2",
    "node-sass": "^4.9.2",
    "node-zopfli": "^2.0.2",
    "numeral": "^2.0.6",
    "path-complete-extname": "^0.1.0",
    "postcss-loader": "^2.0.5",
    "postcss-smart-import": "^0.7.4",
    "precss": "^1.4.0",
    "prop-types": "^15.5.10",
    "rails-erb-loader": "^5.0.2",
    "react": "^15.6.0",
    "react-autosuggest": "^9.3.2",
    "react-avatar-editor": "^11.0.4",
    "react-calendar": "2.11.0",
    "react-cropper": "^1.0.0",
    "react-datepicker": "^1..0",
    "react-dom": "^15.6.0",
    "react-dropzone": "^3.13.4",
    "react-infinite-scroller": "^1.1.4",
    "react-onclickoutside": "^4.9.0",
    "react-primitives": "^0.4.3",
    "react-select": "^2.0.0",
    "react-slick": "^0.14.11",
    "react-styled-select": "^1.1.0",
    "react-svg-inline": "^2.0.0",
    "react-timeago": "^3.4.3",
    "react-visibility-sensor": "^4.1.1",
    "react-waypoint": "^7.0.3",
    "react_ujs": "^2.2.0",
    "reactive-state": "^0.5.8",
    "resolve-url-loader": "^2.0.2",
    "sass-loader": "^6.0.5",
    "select2": "^4.0.6-rc.0",
    "shallowequal": "^1.1.0",
    "smart-app-banner": "^1.5.1",
    "string": "^3.3.3",
    "style-loader": "^0.18.2",
    "url-polyfill": "^1.1.0",
    "validator": "^10.7.1",
    "webpack": "^2.6.1",
    "webpack-manifest-plugin": "^1.1.0",
    "webpack-merge": "^4.1.0"
  },
  "devDependencies": {
    "aglio": "^2.3.0",
    "babel-preset-stage-3": "^6.24.1",
    "react-file-base64": "^1.0.3",
    "react-images-upload": "^1.1.1",
    "react-pace-progress": "^1.0.2",
    "webpack-dev-server": "^2.4.5"
  }
}

这是我导入日期选择器的方式:

import DatePicker from 'react-datepicker';

这就是我在渲染功能中使用它的方式:

<DatePicker 
   customInput={<WinDateInput />}
   ref="expiryDate"
   selected={expiryDate} 
   onChange={this.onChangeDate} 
   minDate={moment().add(1, 'day')} 
   dateFormat="YYYY/MM/DD" 
   id="registration_expiry_date"
/>

当我移除道具时,它不起作用,但是当我移除整个组件时,一切都按预期工作。 我试图删除 package-lock.json 和node_modules并重新运行npm安装,但仍然无法正常工作。

  

节点版本为:v8.11.3   NPM版本为:v6.4.1

2 个答案:

答案 0 :(得分:0)

检查如何导入Firebase

import firebase from 'firebase/app'
import 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

也是本期帖子

https://github.com/firebase/firebase-js-sdk/issues/848

由于信息不足,我认为图像中的警告与错误有关

答案 1 :(得分:0)

您使用的15.x.x至少有react&react-dom版本16.0.0或更高版本的React-datepicker要求。