Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Get global state variable using React.useContext

What I have tried:

I’m fallowing  this approach to create Authentication flow: 

https://reactnavigation.org/docs/auth-flow/

Everything works fine until I create another functional component in a separated file call register.js

In this new component I import the AuthContext created and exported in App.js as described in the documentation:

import {AuthContext} from '../index';

Now I can’t figure out a way to within  "register.js" or any other component, get the state "userToken" to make axios calls.

How can I get the state values from this others components??????????????
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900