简体   繁体   English

React-Navigation和Fetch()的问题

[英]Issueswith React-Navigation and Fetch()

Essentially: I am using react-navigation to navigate between two screens in my app. 本质上:我正在使用反应导航在应用程序的两个屏幕之间导航。 This in principle works fine, I can use the navigation buttons to navigate between screens. 原则上,这可以正常工作,我可以使用导航按钮在屏幕之间导航。

However, I am running in to a problem I am completely unable to troubleshoot because no useful error information is generated. 但是,由于没有生成有用的错误信息,因此我完全无法解决问题。

Basically, each page of the app needs to use fetch() to pull data when it is mounted, and upon first mount of the component it works as expected. 基本上,应用程序的每个页面在安装时都需要使用fetch()来提取数据,并且在首次安装组件时,它会按预期工作。 The issues arises after moving between pages. 在页面之间移动后出现问题。

Essentially it seems to me that fetch() simply stops working after I navigate between screens. 从本质上来说,在屏幕之间导航后,fetch()似乎停止工作。 Basically I need to be able to make some POST and GET requests, however this simply does not work. 基本上,我需要能够发出一些POST和GET请求,但是这根本行不通。 Far as I can tell the calls to fetch() don't even fire. 据我所知,对fetch()的调用甚至不会触发。

If I look at what data is communicated by my app and my server in Wireshark, I can can see that when the components first mount, they communicate just fine over TLS1.2. 如果我查看我的应用程序和服务器在Wireshark中传递的数据,我可以看到当组件首次挂载时,它们通过TLS1.2可以很好地通信。 Then when navigate to one page and navigate back, NO data is sent or received. 然后,当导航到一页并向后导航时,不会发送或接收任何数据。

So my question is, why does switching between app pages seem to make React-native not want to execute fetch() commands any more? 所以我的问题是,为什么在应用程序页面之间切换似乎使React-native不再想要执行fetch()命令?

Code will be provided upon request, but I don't think seeing it will help much since the issue seems unrelated to my specific code. 将根据要求提供代码,但我认为看到它不会有太大帮助,因为该问题似乎与我的特定代码无关。 The code works fine, just as long as I never switch between app pages. 只要我从不在应用程序页面之间切换,代码就可以正常工作。

Despite changing no lines of code. 尽管没有更改任何代码行。 The code now seems to work. 该代码现在似乎可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM