Commit 33a7a479 authored by Adrià Labay's avatar Adrià Labay
Browse files

load stats when prop change and avoid loading on null exam id

parent 8663d36c
......@@ -124,8 +124,19 @@ class Overview extends React.Component {
selectedStudentId: null
}
componentWillMount () {
api.get(`stats/${this.props.examID}`)
componentDidMount = () => {
if (this.props.examID !== null) this.loadStats(this.props.examID)
}
componentDidUpdate = (prevProps, prevState) => {
const examID = this.props.examID
if (examID !== prevProps.examID) {
this.loadStats(examID)
}
}
loadStats = (id) => {
api.get(`stats/${id}`)
.then(stats => {
this.setState({
stats: stats,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment