Answer the question
In order to leave comments, you need to log in
How to organize a simple dashboard in React?
Hello!
There is a web application with a personal account.
When the user is not authorized, he is shown the main and static pages, when he is authorized, he gets to the control panel and there he can already navigate through all the pages.
I don't use redux because the application is not big and all registration is done through firebase, but I ran into a problem: my header and footer go in separate stupid components.
They need to display either information about the current user, or login/registration buttons.
I see 2 options:
1. Make the Header state, and throw a request for onAuthStateChanged again - which is not cool, because I do not want to produce unnecessary queries to the database
2. Transfer all the necessary data to the Header on each page, which is also not cool, because if something changes, you will have to change it on all pages
Answer the question
In order to leave comments, you need to log in
Use the state management library (Redux, MobX, etc) They were written to solve such problems.
Another option is to throw the user's data into the context. But it is better to fasten the state management library.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question