React Native Snap Carousel ref 在导航到具有不同参数的同一页面时变得空

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

React Native Snap Carousel 包的引用在重新渲染具有不同参数的相同组件时变为空。

到目前为止我尝试了什么 由于该包使用 react native flatlist 作为其实现,所以我将我的代码修改为 flatlist 视图并且没有显示错误

下面是发生的一些日志 Object -> Navigate -> Null -> Object

我今天刚刚发布了 version 3.3.0 插件,应该可以解决您的问题。

如果您想更深入地了解相关问题,请参阅 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

此外,Animated 组件似乎有时会在它们的父级之前卸载...