mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
Only rerender NarrativeCard if step has changed
This commit is contained in:
committed by
Lachlan Kermode
parent
4423e792ec
commit
40ac0eb120
@@ -94,10 +94,13 @@ class Dashboard extends React.Component {
|
||||
getCategoryColor: category => this.getCategoryColor(category)
|
||||
}}
|
||||
/>
|
||||
<NarrativeCard
|
||||
onSelect={this.handleSelect}
|
||||
onSelectNarrative={(narrative) => { this.props.actions.updateNarrative(narrative); }}
|
||||
/>
|
||||
{(this.props.app.narrative !== null)
|
||||
? <NarrativeCard
|
||||
onSelect={this.handleSelect}
|
||||
onSelectNarrative={(narrative) => { this.props.actions.updateNarrative(narrative); }}
|
||||
/>
|
||||
: ''
|
||||
}
|
||||
<CardStack
|
||||
onSelect={this.handleSelect}
|
||||
onHighlight={this.handleHighlight}
|
||||
|
||||
@@ -23,8 +23,13 @@ class NarrativeCard extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.props.narrative !== null) {
|
||||
componentDidMount() {
|
||||
const step = this.props.narrative.steps[this.state.step];
|
||||
this.props.onSelect([step]);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevProps.narrative === this.props.narrative && this.state.step !== prevState.step) {
|
||||
const step = this.props.narrative.steps[this.state.step];
|
||||
this.props.onSelect([step]);
|
||||
}
|
||||
@@ -42,7 +47,7 @@ class NarrativeCard extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.narrative !== null && this.props.narrative.steps[this.state.step]) {
|
||||
if (this.props.narrative.steps[this.state.step]) {
|
||||
const steps = this.props.narrative.steps;
|
||||
const step = steps[this.state.step];
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ function updateSelected(appState, action) {
|
||||
}
|
||||
|
||||
function updateNarrative(appState, action) {
|
||||
console.log('this happens')
|
||||
if (action.narrative === null) {
|
||||
return Object.assign({}, appState, {
|
||||
narrative: action.narrative,
|
||||
|
||||
@@ -163,7 +163,6 @@ export const selectLocations = createSelector(
|
||||
export const selectSelected = createSelector(
|
||||
[getSelected, getSources],
|
||||
(selected, sources) => {
|
||||
console.log(selected, sources)
|
||||
if (selected.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user