Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sruthisripathi opened this issue Apr 4, 2018 · 7 comments

Comments

@sruthisripathi
Copy link

sruthisripathi commented Apr 4, 2018

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

@arieu
Copy link

arieu commented Apr 18, 2018

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
Copy link

arieu commented Apr 24, 2018

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.

@TeyimPila
Copy link

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"

@sylviestephanies
Copy link

Is there any update on this?

@wade-montague
Copy link

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.

@sonirico
Copy link

sonirico commented Nov 15, 2018

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.

@jeemonputhusseri
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants