App crash with React-datepicker 1.8, React 16.6.3.
Console :
react-dom.development.js:57 Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
at invariant (react-dom.development.js:57)
at scheduleWork (react-dom.development.js:19364)
at Object.enqueueSetState (react-dom.development.js:12789)
at DatePicker.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:354)
at DatePicker.componentDidUpdate (index.js:3010)
at commitLifeCycles (react-dom.development.js:16737)
at commitAllLifeCycles (react-dom.development.js:18160)
at HTMLUnknownElement.callCallback (react-dom.development.js:147)
at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
at invokeGuardedCallback (react-dom.development.js:250)
at commitRoot (react-dom.development.js:18365)
at completeRoot (react-dom.development.js:19894)
at performWorkOnRoot (react-dom.development.js:19817)
at performWork (react-dom.development.js:19722)
at performSyncWork (react-dom.development.js:19696)
at requestWork (react-dom.development.js:19551)
at scheduleWork (react-dom.development.js:19358)
at Object.enqueueSetState (react-dom.development.js:12789)
at DatePicker.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:354)
at DatePicker._this.setOpen (index.js:2551)
at Object.DatePicker._this.handleCalendarClickOutside [as onClickOutside] (index.js:2625)
at Calendar._this.handleClickOutside (index.js:1807)
at onClickOutside._this.__outsideClickHandler (react-onclickoutside.es.js:182)
at HTMLDocument.handlersMap.(anonymous function) (http://localhost:3000/static/js/4.chunk.js:10985:17)
I see this happening when an invalidate date (new Date("")) is passed in to selected. I wonder if that's the root cause to your issue.
it seems like https://github.com/ant-design/ant-design/issues/11957.
I got the same issue when I used this.state = { startDate: moment() }; Use moment().valueOf(). This will fix this issue
That helps me:
const { startDate } = this.state;
...
selected={value !== '' ? new Date(startDate) : null}
Any updates on this? This bug just cost me 1 hour of my time to figure out, just because react-datepicker doesn't manage to handle invalid dates without crashing the whole damn react application - absolutely ridiculous.
I'm having the same error, I'm using redux-form with "revalidate" and anytime I try to type anything other than a date in the input the whole app crashes with that error.
I'm having the same error (((
@JackHull @Shaker-Hamdi This is due to the version, I lowered the version to 1.4.1 and it works
Hi guys, any news on this ? :/
@maxsd Apparently not - the easiest workaround is to check the date for validity yourself, before passing it to react-datepicker - this bug just seems to happen as soon as react-datepicker receives an invalid date object.
This error also happen when you use the configuration of Date Range from the lib and put the isClearable option in the fields. When i try to clear the field i get this error.
Am i doing something wrong? or is it a bug from the library?
try this:
var dateobject=new Date (moment(" "))
this will work in chrome as well as in ie
I'm having the exact same issue with DatePicker. When I add inline parameter dateFormat this exception occurs. I'm using Redux Form and rendering the DatePicker through the component parameter of the Field.
It is very weird that minDate and maxDate can accept the result of moment(), but with selected you have to specifically parse the result with toDate() to make it work.
Besides, crashing the whole application because of the wrong date format is absolutely ridiculous.
Yes inline parameter dateFormat causing issue.
Thanks manthis
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Any updates on this? This bug just cost me 1 hour of my time to figure out, just because react-datepicker doesn't manage to handle invalid dates without crashing the whole damn react application - absolutely ridiculous.