RN single page system login page Navigator problem

Source: Internet
Author: User
Tags reset

React-native & Reduce.


Problems with developing mobile apps today: After resetting the password, log back in and the page returns to the Reset Password page.

And the expected result is any time, login to enter the home page.



Original logic:

Navigator routing, determine the login status, if not logged in, skip the login page, otherwise use Navigation route.

Cause of the problem:

The problem with this logic is that if the route is not empty when logged out, the login state changes to go directly to the current routing navigation page.


Difficulty 1: The login status is saved in reduce and cannot be heard in the transient state of the change. This means that all pages only know that the current is logged in/not logged in, but no status is ' just logged in '. Difficulty 2: In the process of judging the route and rendering, it is impossible to modify the current Navigation route, which will cause the state conflict problem.

Workaround 1:

When logged out, do a fake jump to reset the route to the homepage. Said to be a fake jump, because the logout status will allow the app to enter the login page.

The problem with this scenario is that this problem may still occur again on other pages. False jumps affect performance.


Workaround 2:

The login page is also placed in a route, which is no longer directly redirected to the login page by the logon state, but is routed.

The problem with this scenario is that you need to tightly control the order in which routes and login states are rendered before initiating the logout.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.