【问题标题】:Fetching large amount of data with React native使用 React Native 获取大量数据
【发布时间】:2019-09-23 20:11:41
【问题描述】:

正在开展一个项目,对于某些用户,我们需要获取大量数据。在模拟器上似乎很好,但是在运行真正的 iOS/iPhone 设备时可能会很慢。由于 react-native/js 是单线程的,多线程可能不是一个选项

想知道缓解这种情况的好方法是什么

【问题讨论】:

    标签: reactjs multithreading performance react-native single-threaded


    【解决方案1】:

    能够通过 InteractionManager https://facebook.github.io/react-native/docs/interactionmanager 解决问题,本质上它会在任何交互/动画完成后延迟要安排的长期工作

    componentDidMount() {
    
        InteractionManager.runAfterInteractions(() => {
          // ...long-running synchronous task...
          fetch([url], {
    
          }).then((response) => {
    
          })
        })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      • 1970-01-01
      • 2020-06-03
      • 2021-04-06
      • 2015-06-30
      • 1970-01-01
      • 2019-08-09
      相关资源
      最近更新 更多