2

Please see snapshot attached: Code Snippet

I'm trying to export this variable "email" from the 'List' screen, to the 'Account' screen without having to navigate to it as it is a bottomTabNavigator.

Any help would be very appreciated!

Here's the repo: GitHub Repo

  • Use redux to share state between components. https://www.npmjs.com/package/react-redux – Emil Karlsson Nov 30 '21 at 12:03
  • Or use a parent component that keeps the state for both child components. Or you can even use `context` to share a state between components. – Kokodoko Nov 30 '21 at 12:13

2 Answers2

1

some way you can handle that :

  1. use redux in your project for access to your states in all of your project

for more info see this

this solution totally used in big project

  1. use createContext to save your some props and you can access that in other Screen for more info see this

3.use global prop in project and you can set and get from that

for Example for set like that :

global.myProb=5;

and for get:

var m=global.myProb;
  1. use AsyncStorage for save some data . for more info see this
Meisan Saba
  • 800
  • 2
  • 9
  • 25
  • Thanks for the 360-degree answer, I opted for the createContext approach and it did the trick! The other 3 ways are new to me and are definitely worth looking into. Thanks! – federico-pi Dec 01 '21 at 13:24
0

It depends on which sort of state management are you using. In case of redux you can simply have a state that you communicate between the screens or create a top level context with reducers hook to pass the data.

Noman
  • 594
  • 1
  • 18