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
If you are new to react (as me) and got confused by the first answer. First, use a component Class
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
walk: true
};
GLOBAL.screen1 = this;
}
render() {
return (
{this.state.walk ? (
<>
>
) : (
)}
)
}
Then you can do in any other component (My components are on /components, global is on root):
import GLOBAL from '../global.js'
GLOBAL.screen1.setState({walk:false})