Search code examples
reactjsreact-nativereact-statereact-state-management

How to pass variable between screens in react native (see attached)


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


Solution

  • 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