react-bootstrap-datetimerangepicker icon indicating copy to clipboard operation
react-bootstrap-datetimerangepicker copied to clipboard

Cannot read property 'any' of undefined at startDate: PropTypes.any

Open sruthisripathi opened this issue 6 years ago • 7 comments

Hi I am getting the following error when I used one of your examples in my project Cannot read property 'any' of undefined When I followed the error in bundle file, it showed the error at proptype definitions in the DatetimeRangePicker component


  static propTypes = {

    startDate: PropTypes.any,
    endDate: PropTypes.any,
    children: PropTypes.any,
    className: PropTypes.string,
    style: PropTypes.object,

    callback: PropTypes.func,
    onEvent: PropTypes.func,
    onShow: PropTypes.func,
    onHide: PropTypes.func,
    onShowCalendar: PropTypes.func,
    onHideCalendar: PropTypes.func,
    onApply: PropTypes.func,
    onCancel: PropTypes.func,
  };

at startDate: PropTypes.any

sruthisripathi avatar Apr 04 '18 06:04 sruthisripathi

Hi Sruthi, I have the same problem. It looks like React.PropTypes is deprecated as of React v15.5. I think downgrading to a supported version would fix this but I am going to fork this and change to the prop-types version for later versions of React.

https://stackoverflow.com/questions/44573199/cannot-read-property-string-of-undefined-react-proptypes-layoutproptypes-j

https://www.npmjs.com/package/prop-types

arieu avatar Apr 18 '18 21:04 arieu

Update: You can just use the files in the "src" folder as regular react components to get this working. Make sure to install all dependencies.

arieu avatar Apr 24 '18 21:04 arieu

Is there any way around this yet? I am facing the same issue and it is stopping me from using the package. @arieu, please what do you mean by "Using the files in src"

TeyimPila avatar May 14 '18 09:05 TeyimPila

Is there any update on this?

sylviestephanies avatar Jun 20 '18 02:06 sylviestephanies

This is quite an easy fix relating to the later versions of React. PropTypes are no longer included as part of the 'react' component so you need to import them separately. Since the new usage of PropTypes is also different you will need to adjust some a tiny bit of source for this module.

There are a couple of ways to do this. Either edit the node src file yourself:

\node_modules\react-bootstrap-datetimerangepicker\lib\index.js

step 1: ln42 - ln55 remove all instances of _react2['default']. step 2: ln22 add var PropTypes = require('prop-types'); step 3: (optional) If you don't have prop-types in your root package.json then add "prop-types": "^15.6.2", to dependencies and run an update.

Original: startDate: _react2['default'].PropTypes.any, endDate: _react2['default'].PropTypes.any, children: _react2['default'].PropTypes.any, className: _react2['default'].PropTypes.string, style: _react2['default'].PropTypes.object, callback: _react2['default'].PropTypes.func, onEvent: _react2['default'].PropTypes.func, onShow: _react2['default'].PropTypes.func, onHide: _react2['default'].PropTypes.func, onShowCalendar: _react2['default'].PropTypes.func, onHideCalendar: _react2['default'].PropTypes.func, onApply: _react2['default'].PropTypes.func, onCancel: _react2['default'].PropTypes.func

New startDate: PropTypes.any, endDate: PropTypes.any, children: PropTypes.any, className: PropTypes.string, style: PropTypes.object, callback: PropTypes.func, onEvent: PropTypes.func, onShow: PropTypes.func, onHide: PropTypes.func, onShowCalendar: PropTypes.func, onHideCalendar: PropTypes.func, onApply: PropTypes.func, onCancel: PropTypes.func

The second option is basically the same as the above but using the un gulped src file (\node_modules\react-bootstrap-datetimerangepicker\src\index.js) and lifting the component out of the node_models into a component of your own.

wade-montague avatar Oct 04 '18 15:10 wade-montague

I strongly believe that the correct approach to solve this issue would be bumping a 3.X.X version with the prop-types package accordingly installed. Urging people to merely import source files instead of dist code should be totally discouraged.

sonirico avatar Nov 15 '18 14:11 sonirico

Is there any proper solutions for the issue, apart from this the package works nice and well

jeemonputhusseri avatar Jan 13 '20 14:01 jeemonputhusseri