希望创建对 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的类型,因此不确定这是否是定义的错误,或者只是我没有正确使用它。