fix stats graph on refresh

This commit is contained in:
Sam
2019-01-04 15:23:03 +01:00
parent a13d00d5d9
commit 3b499524ca
2 changed files with 25 additions and 17 deletions

View File

@ -30,6 +30,17 @@ class Statistics extends React.Component {
}
}
componentDidUpdate(prevProps) {
if (this.props.sports !== prevProps.sports) {
this.updateDisplayedSports()
}
}
updateDisplayedSports() {
const { sports } = this.props
this.setState({ displayedSports: sports.map(sport => sport.id) })
}
handleOnChangeDuration(e) {
const duration = e.target.value
const date = new Date()