0

I get the UserName and other information about the user from the server by Axios after a successful login and I want to pass this information to my Header component to show it on all pages.

I can send properties by <Header userName={this.state.UserName} to the Header component and it is okay, but when I go to another component from header I lose it and must set state for save username.

Is there any solution to have some property in all Components like Session in Java?

ksav
  • 13,381
  • 5
  • 27
  • 51

1 Answers1

1

Yes there are solutions to use some property in all components in React. You will need a state management tool for this. The 2 most commonly used ones are Redux and React's Context API.

SR810
  • 218
  • 2
  • 5