简体   繁体   English

navigation.goback() 缺少数据

[英]data is missing with navigation.goback()

In my React Native app, I had three screens like A and B .在我的 React Native 应用程序中,我有三个屏幕,例如AB I navigate from one screen to another using react-navigation version 5.我使用react-navigation版本 5 从一个屏幕导航到另一个屏幕。

When I move from A to B and enter some data in B, and move from B to A to verify the data entered in A is correct and again entered from A to B , my data in B screen is not there.当我从A移动到B并在 B 中输入一些数据,并从B移动到A以验证在A中输入的数据是否正确并再次从A输入到B时,我在B屏幕中的数据不存在。

I am using navigation.goBack() .我正在使用navigation.goBack() I am not using any global state.我没有使用任何全局 state。 How can I make data entered to be visible even I go back and entered the screen?即使我 go 返回并进入屏幕,如何使输入的数据可见?

If you use goBack() to go from B -> A, B gets unmounted and loses params that you initially passed.如果您从 B -> A 使用goBack()到 go,B 将被卸载并丢失您最初传递的参数。 You would have to either pass it again when going from A -> B or use a central state like Context , Redux etc.从 A -> B 出发时,您必须再次传递它,或者使用中央 state ,如ContextRedux等。

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

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