From 9e16271dbbf2fc7397367507110065f8a3cde50f Mon Sep 17 00:00:00 2001 From: Franc Camps-Febrer Date: Tue, 18 Dec 2018 15:37:39 +0100 Subject: [PATCH] Reset narrative to first event when switching between narratives --- src/components/NarrativeCard.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/NarrativeCard.js b/src/components/NarrativeCard.js index 080ae85..67a6bbc 100644 --- a/src/components/NarrativeCard.js +++ b/src/components/NarrativeCard.js @@ -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]); + }); } }