data is missing with navigation.goback()

Viewed 384

In my React Native app, I had three screens like A and B. I navigate from one screen to another using react-navigation version 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.

I am using navigation.goBack(). I am not using any global state. How can I make data entered to be visible even I go back and entered the screen?

1 Answers

If you use goBack() to go from B -> A, B gets unmounted and loses params that you initially passed. You would have to either pass it again when going from A -> B or use a central state like Context, Redux etc.

Related