gpt4 book ai didi

react-native - react native : Optimized SectionList does not rerender after scrollToLocation

转载 作者:行者123 更新时间:2023-12-04 02:16:34 24 4
gpt4 key购买 nike

我构建了一个滚动 SectionList 的字母擦洗器。 SectionList 通过使用 getItemLayout 进行了优化。如果我擦洗字母表,滚动会按计划进行,但在我从屏幕上松开手指之前,SectionList 不会重新呈现。

See this expo snack

关于如何解决这个问题的任何想法?

Screenshot of example

最佳答案

通过查看 PanResponder 的源代码解决了它。 PanResponder 通过 InteractionManager 设置交互句柄。您可以通过 this.panResponder.getInteractionHandle() 访问此句柄(未记录的功能),然后在每次滚动到 SectionList 中的某个位置时清除它:

if (this.panResponder.getInteractionHandle()) {
InteractionManager.clearInteractionHandle(
this.panResponder.getInteractionHandle()
);
}

这将在队列中向上移动 SectionList 以进行其可见性计算和渲染。

我建议通过尽可能少地清除交互句柄来对此进行大量优化,因为 InteractionManager 是出于性能原因使用的。

关于react-native - react native : Optimized SectionList does not rerender after scrollToLocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47411170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com