小编Kie*_*ood的帖子

在 ScrollView 反应本机上添加 useRef 的类型

希望创建对 ScrollView 组件的引用,如下所示:(const ref = useRef<ScrollView>(null);或类似效果)本质上我需要访问flashScrollIndicators如下方法:

<ScrollView
  ref={ref}
  onContentSizeChange={() => ref?.current?.flashScrollIndicators()}>
  {children}
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

该代码确实在我的应用程序中工作,但是 ScrollView 的打字稿定义似乎不包括 flashScrollIndicators?我正在Property 'flashScrollIndicators' does not exist on type 'ScrollView'.ts(2339)查看可以看到SectionList和Flatlist的类型,因此不确定这是否是定义的错误,或者只是我没有正确使用它。

typescript react-native

11
推荐指数
1
解决办法
4764
查看次数

标签 统计

react-native ×1

typescript ×1