I am trying to study React Navigation from the documentation and have read this quote
When going back from B to A, componentWillUnmount of B is called, but componentDidMount of A is not because A remained mounted the whole time.
Here is my question: Why was the WillUnmount called for the B component, but the WillUnmount was not called for the A component?
I know it is for the performance, but what pages are the WillUnmount calls for, and which pages are the WillUnmount calls not?
CodePudding user response:
From above example, A is main screen and B is the second screen which was stacked over A, so think it like that A is still there and B is just over A, so when going back from B to A, B will be removed (unmounted) from that stack and hence WillUnmount of B will be called, but A is not removed from stack and WillUnmount of A won't called until we exit the app or put screen A stacked over another screen and going back.
