createNavigationContainer: cache previously used navigation when stateful (#202)

Prevents unnecessary creating new navigation objects when the container is passing through other props that are changing
This commit is contained in:
Emiel Mols
2017-02-06 18:12:33 +01:00
committed by Satyajit Sahoo
parent aead8ff9fb
commit 33767311ae

View File

@@ -148,10 +148,13 @@ const createNavigationContainer = (
render() {
let navigation = this.props.navigation;
if (this._isStateful()) {
navigation = addNavigationHelpers({
dispatch: this.dispatch.bind(this),
state: this.state.nav,
});
if (!this._navigation || this._navigation.state !== this.state.nav) {
this._navigation = addNavigationHelpers({
dispatch: this.dispatch.bind(this),
state: this.state.nav,
});
}
navigation = this._navigation;
}
return (
<Component