I don't know if I have used the right terminology, but this is what I am trying to do. I am fetching some header details from one of my API's which includes the bearer token, and other details. These values will be used by most of the other react components. Is there a way to store it globally without using Redux or passing the data to all the individual components?
Below is a code snippet which gets the value from the state of the location of a React component. I need to store these values globally without using redux.
if (response.httpStatus === 200) {
setIsLoggedIn(true);
//setIsAdmin(response.user.isAdmin!);
setEmailAddress(inputEmailAddress);
history.push('/console',{
token:response.token,
companyID: response.user.companyID,
firstName: response.user.firstName,
lastName: response.user.lastName,
emailAddress: response.user.emailAddress
} //<--- I also need to store this object globally in the browsers scope so that they can be used by all other react components.
);
}
My question might sound silly and might lack the right terminologies. My work is mostly in the API and the database. I don't have much expertise or knowledge using react.