Ok! On the Android phone, when we use the physical return key, will be a one-time program exit, this is a very bad experience, so we need to use the physical return key component of Rn: Backandroid, the principle is
Analyze the route and then pop () like this!
Ok! Let's start with the routing stack! , a bit of computer technology based on the students should learn the stack, which is the stack is the back into first out, that is, RN inside the push (into the stack), pop (out of the stack)!
Good!!
1: A backandroid between two routes
else return exit the app directly
2: In the Registration component settings backandroid (note here, in the registration component, other not OK OH)
At this point we can see that the navigator is obtained from the sub-component through refs! (The child component gets the parent component, props, the parent component gets the child component: refs), and then we set it in the parent component: REF
That's it!
Precautions:
Expand: Two return, add hint:
Ok! That's it
The backandroid of React native Components! Use of physical return keys for Android phones