mirror of
https://github.com/status-im/react-native.git
synced 2025-03-03 02:40:31 +00:00
clean up navigator when it's unmounted.
Summary: public We've noticed that some of the navigator functions are called after the navigator being unmounted. This diff adds the checks to protect the navigator from throwing error when it's calling function after be unmounted. Reviewed By: fkgozali Differential Revision: D2629484 fb-gh-sync-id: 1cbee02b1a8d2a5d285e7d76f382d2599ed8caed
This commit is contained in:
parent
bbee3c6f60
commit
1f0566f55f
@ -348,7 +348,12 @@ var Navigator = React.createClass({
|
||||
this._navigationContext.dispose();
|
||||
this._navigationContext = null;
|
||||
}
|
||||
this.spring.removeAllListeners();
|
||||
|
||||
this.spring.destroy();
|
||||
|
||||
if (this._interactionHandle) {
|
||||
this.clearInteractionHandle(this._interactionHandle);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -414,6 +419,9 @@ var Navigator = React.createClass({
|
||||
* happening, we only set values for the transition and the gesture will catch up later
|
||||
*/
|
||||
_handleSpringUpdate: function() {
|
||||
if (!this.isMounted()) {
|
||||
return;
|
||||
}
|
||||
// Prioritize handling transition in progress over a gesture:
|
||||
if (this.state.transitionFromIndex != null) {
|
||||
this._transitionBetween(
|
||||
@ -435,6 +443,10 @@ var Navigator = React.createClass({
|
||||
* This happens at the end of a transition started by transitionTo, and when the spring catches up to a pending gesture
|
||||
*/
|
||||
_completeTransition: function() {
|
||||
if (!this.isMounted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.spring.getCurrentValue() !== 1 && this.spring.getCurrentValue() !== 0) {
|
||||
// The spring has finished catching up to a gesture in progress. Remove the pending progress
|
||||
// and we will be in a normal activeGesture state
|
||||
|
Loading…
x
Reference in New Issue
Block a user