Home > Software engineering >  How to pass variable between screens in react native (see attached)
How to pass variable between screens in react native (see attached)

Time:11-30

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

CodePudding user response:

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.

CodePudding user response:

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
  • Related