Skip to content

Commit a98c076

Browse files
committed
Use the standard pattern to sync a state change
1 parent 9d5db9c commit a98c076

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

app/component/PrintableItinerary.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,16 @@ class PrintableItinerary extends React.Component {
378378
index={i}
379379
originalLegs={originalLegs}
380380
context={this.context}
381-
mapsLoaded={() => {
382-
const mapsLoaded = this.state.mapsLoaded + 1;
383-
this.setState({ mapsLoaded });
384-
if (
385-
mapsLoaded >=
386-
originalLegs.filter(o2 => o2.mode === 'WALK').length
387-
) {
388-
setTimeout(() => window.print(), 1000);
389-
}
390-
}}
381+
mapsLoaded={() =>
382+
this.setState({ mapsLoaded: this.state.mapsLoaded + 1 }, () => {
383+
if (
384+
this.state.mapsLoaded >=
385+
originalLegs.filter(o2 => o2.mode === 'WALK').length
386+
) {
387+
setTimeout(() => window.print(), 1000);
388+
}
389+
})
390+
}
391391
/>
392392
</div>
393393
);

0 commit comments

Comments
 (0)