mailcubano hide Ответов: 0

Поделитесь глобальным состоянием с помощью react.createcontext() и react.usecontext


Получить глобальную переменную состояния с помощью React.useContext

Что я уже пробовал:

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??????????????

0 Ответов