react-date-range icon indicating copy to clipboard operation
react-date-range copied to clipboard

Errors with react list at Calendar mount

Open bhritchie opened this issue 5 years ago • 2 comments

Errors with react list at Calendar mount

I am seeing regular errors like this in production: null is not an object (evaluating 'this.list.getVisibleRange') .

The error is that this.list is null in Calendar.focusToDate (https://github.com/Adphorus/react-date-range/blob/master/src/components/Calendar/index.js#L83), after being called from componentDidMount:

componentDidMount() {
  if (this.props.scroll.enabled) {
    // prevent react-list's initial render focus problem
    setTimeout(() => this.focusToDate(this.state.focusedDate));
  }
}

I note the comment: "prevent react-list's initial render focus problem" - I wonder if the 0ms timeout is not always sufficient? Does this seems like a likely cause, and, if so, can anyone suggest a resolution?

[BUG] Bug Reproduce Steps

I don't know how to reproduce the issue. I suspect it is a sporadic issue related to react-list not being available when componentDidMount runs.

[BUG] Expected behaviour

No error.

Environment

Package Version: 1.0.3 React version: 16.8.6 Browser: Various

Thanks in advance.

bhritchie avatar May 25 '20 09:05 bhritchie

I also have this issue w/ the latest 1.4.0

index.js:152 Uncaught TypeError: Cannot read properties of null (reading 'getVisibleRange')
    at Calendar.focusToDate

pofixifop avatar Dec 09 '21 18:12 pofixifop

I'm having the same issue, any updates ?

HTaiNguyen avatar Mar 23 '22 10:03 HTaiNguyen