React Native Snap Carousel ref getting null on navigating to same page with different params

684 Views Asked by At

enter image description here

The ref of the React Native Snap Carousel package is becoming null on re rendering the same component with different params.

What I have tried till now Since the package used react native flatlist as its implementation, so i modified my code to the flatlist view and that shows no error

Here are some of the logs of what happens Object - > Navigate - > Null - > Object

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

I've just released version 3.3.0 of the plugin today, which should solve your issue.

If you want a deeper understanding of the issue at stake, see this React Native thread. Basically, one should apparently avoid using stateless components when rendered inside scroll components. They should be migrated to regular components that extend Component or PureComponent. See this comment or this one.

Also, it seems that Animated components are sometimes unmounted before their parents...