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

Viewed 20

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.

1 Answers

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

Related