美文网首页
ReactNative中遇到的各种问题

ReactNative中遇到的各种问题

作者: raosy | 来源:发表于2017-08-04 20:06 被阅读0次

    1. undefined is not an object (evaluating 'regeneratorRuntime.mark')

    原因:

    更新react版本引起
    

    解决:

       rm -rf   node_modules/
       npm i/install
    

    尝试后发现仍然报错,之后删除app,重新安装运行,不再报错(原因未深究)。
    参考:undefined is not an object (evaluating 'regeneratorRuntime.mark')

    2. 使用react-native-scrollable-tab-view,tab滑动切换很卡

    原因:

    切换tab时,当前tab下的内容会重新渲染
    

    解决:

    shouldComponentUpdate(nextProps, nextState),使tab中内容只有在数据有变化时更新
    

    只有在首次加载数据时切换tab会卡一下,之后滑动tab不再卡

    3. react native中使用FlatList,同时使用onEndReached和onRefresh时,每次下拉加载数据onRefresh时会触发一次onEndReached

    原因:

    应该是FlatList bug 当前rn版本为0.47.0
    

    解决:

    设置onEndReachedThreshold={0}
    后续:
    事实证明设为0可能会导致不触发onEndReached
    最后通过在onEndReached处理函数中判断onRefresh发生时不执行
    

    参考:FlatList问题?

    相关文章

      网友评论

          本文标题:ReactNative中遇到的各种问题

          本文链接:https://www.haomeiwen.com/subject/yclblxtx.html