BugiDev / react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.
MIT License
933 stars 325 forks source link

Component exception: cannot read property scrollToIndex of undefined #306

Closed nagesh-bv closed 2 years ago

nagesh-bv commented 3 years ago

Hi there, Im facing this issue with the following version: "react-native-calendar-strip": "^2.2.3"

MicrosoftTeams-image

Thank you.

nagesh-bv commented 3 years ago

As I debug it and found that this.rlv is coming undefined

majugurci commented 3 years ago

Can confirm, same thing happening in my app. My home screen contains react-native-calendar-strip and when I change some file which reloads the whole app this is happening. If i make some smaller change which reloads only home screen then it is working fine. Also this is happening in versions 2.2.3 and 2.2.2. In version 2.2.1 everything is OK.

rdoylespk commented 2 years ago

@majugurci

got the same problem today with version 2.2.4

Downgrading to 2.2.1 fixed the issue

Thanks

harking commented 2 years ago

Yup, in 2.2.2, a change was made to add a scrollToDate on componentDidUpdate. If the component props change before the itemHeight is calculated, this.rlv will not be defined yet. See https://github.com/BugiDev/react-native-calendar-strip/compare/2.2.1...2.2.2

Rolling back to 2.2.1 will work-around until a fix is made.

Possible fixe: Add null check for this.rlv in this.scrollToDate

peacechen commented 2 years ago

Please create a PR that checks for this.rlv. Thanks for debugging this issue.

Waseem6409 commented 2 years ago

Please create a PR that checks for this.rlv. Thanks for debugging this issue.

I have fixed the issue and created PR accept it

peacechen commented 2 years ago

Fix published in 2.2.6

Thanks @adamgajzlerowicz and everyone who contributed to this fix