Answer the question
In order to leave comments, you need to log in
Authorization in react native router?
I still don’t really understand how to use and why Redux is needed, where to store what, so don’t kick it. I have a simple react-native application with authorization. The server has 2 urls - /auth, /clientData. When requesting /auth, a login-password is transmitted, if authorization is successful, a token is returned, which is substituted in the headers. /clientData returns data about the user. On the client, I store the token in AsyncStorage.
How can I transfer the user to the personal account when the application is launched, if he is authorized or to the authorization page, if not? Or is it worth doing this directly in the Login component, and then transfer it to the Cabinet component? Ideally, I want to make socket.io support to update user data on the client sidereal-time. How to get its data so that later it can be used in other components without reloading? I searched for open-source similar applications, but didn't find any. I would be grateful for links to such.
Answer the question
In order to leave comments, you need to log in
And so, in the first place, the task is to determine, when loading the application, whether the login data has been saved / whether the login has been completed.
You can use AsyncStorage, or you can Redux with redux-persist (in fact, this is also a local save, but it’s more convenient to work with Redux.)
Well, now when the application starts, we turn to the store, if we have login data, open the cabinet, or knock on / auth if you need to confirm the data.
You can open an account, show a loader, if the data is incorrect, go to the authorization page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question