I am developing a React Native application.
I want to save the user id of the person who is logged in and then check if the user is logged in in every single compone
I usually create a global.js containing:
module.exports = { screen1: null, };
And get the value of the state on the screen
import GLOBAL from './global.js' constructor() { GLOBAL.screen1 = this; }
Now you can use it anywhere like so:
GLOBAL.screen1.setState({ var: value });