Update header when screenProps change (Fixes #4271)

This commit is contained in:
Brent Vatne
2018-06-08 17:35:17 -07:00
parent 152ccbfaf2
commit 7a058892e0
3 changed files with 18 additions and 0 deletions

View File

@@ -65,6 +65,17 @@ export default function ScenesReducer(
prevState,
descriptors
) {
// Always update the descriptors
// This is a workaround for https://github.com/react-navigation/react-navigation/issues/4271
// It will be resolved in a better way when we re-write Transitioner
scenes.forEach(scene => {
const { route } = scene;
if (descriptors[route.key]) {
scene.descriptor = descriptors[route.key];
}
});
// Bail out early if we didn't update the state
if (prevState === nextState) {
return scenes;
}

View File

@@ -22,6 +22,7 @@ class StackView extends React.Component {
<Transitioner
render={this._render}
configureTransition={this._configureTransition}
screenProps={this.props.screenProps}
navigation={this.props.navigation}
descriptors={this.props.descriptors}
onTransitionStart={this.props.onTransitionStart}

View File

@@ -63,6 +63,12 @@ class Transitioner extends React.Component {
nextScenes = filterStale(nextScenes);
}
// Update nextScenes when we change screenProps
// This is a workaround for https://github.com/react-navigation/react-navigation/issues/4271
if (nextProps.screenProps !== this.props.screenProps) {
this.setState({ nextScenes });
}
if (nextScenes === this.state.scenes) {
return;
}