onefinestay / react-daterange-picker

Other
563 stars 209 forks source link

setState error #120

Open nhunsaker opened 8 years ago

nhunsaker commented 8 years ago

I have an application that shows the calendar picker in a modal then removes it when the user selects a full date range. That causes this error: Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the CalendarDate component. It's caused by CalendarDate.jsx line 62:

    this.setState({
      mouseDown: true,
    });

Let me know if you have any recommendations for dealing with this issue.

cp commented 8 years ago

Any insight into this? Happening to me too :(

AlanFoster commented 8 years ago

When in the life cycle do you remove the React element?

cp commented 8 years ago

@AlanFoster what do you mean? not sure if I follow.

samueldelesque commented 8 years ago

This occurs when you unmount the daterange-picker (i.e. I was mounting conditionally based on state of higher order component). The mouse events described above should be unsubscribed on componentWillUnmount.

yrik commented 8 years ago

Have the same issue.. The code is similar to:

{this.state.expanded ? (<DateRangePicker>: null)}

this.state.expanded is changed on daterange-picker onSelect