Reset narrative to first event when switching between narratives

This commit is contained in:
Franc Camps-Febrer
2018-12-18 15:37:39 +01:00
committed by Lachlan Kermode
parent 196abd27b0
commit 9e16271dbb

View File

@@ -32,6 +32,13 @@ class NarrativeCard extends React.Component {
if (prevProps.narrative === this.props.narrative && this.state.step !== prevState.step) {
const step = this.props.narrative.steps[this.state.step];
this.props.onSelect([step]);
} else if (prevProps.narrative !== this.props.narrative && this.props.narrative !== null) {
this.setState({
step: 0
}, () => {
const step = this.props.narrative.steps[this.state.step];
this.props.onSelect([step]);
});
}
}