Gun
Gun

Reputation: 33

What is the way of passing data to another screen whithout navigating in React Native

So I'm trying to send some objects to another screen but the problem is when I use navigation.navigate('ScreenName', {object}) I'm passing the data but also navigating to the secreen as well. I just want to pass the data without navigating to the screen itself and when needed I can go to that screen and view the data I sent.

Upvotes: 0

Views: 90

Answers (1)

MKW
MKW

Reputation: 41

Sounds like you need a state management solution of some sort.

Without seeing what your code looks like it's hard to know what the best solution would be for you , but perhaps try keeping that object in a Context / Provider which can be shared / subscribed to by both screens.

https://reactjs.org/docs/context.html

Upvotes: 1

Related Questions