React Native 0.66.5,仅在调试模式下 json() 挂起在某些 API 调用上

问题描述 投票:0回答:0

在我的 React Native 应用程序中,我最近将

react-native
0.65.3
更新为
0.66.5
。我使用以下代码进行 API 调用:

return fetch(<URL>)
    .then(response => {
        return response.json()
            .then(...)
            .catch(err => {<handle error>})
    })
    .catch(err => {<handle error>})

我进行了 4 次 API 调用。当我 not 处于调试模式时,所有四个都可以正常工作。当我 am 在调试模式下时,前两个工作正常,但对于第三次调用,

json()
永远不会解析,因此它不会进入内部
then
catch
块。

从2016年的这篇帖子开始,有人建议在

setTimeout(() => null, 0);
之前添加
return response.json()
或者点击屏幕,但是这些都没有什么不同。

任何人都可以建议如何处理这个问题吗?

reactjs react-native promise es6-promise fetch-api
© www.soinside.com 2019 - 2024. All rights reserved.