Progress tab: fix switching sections errors #22082
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We were getting reports of errors occasionally when switching between sections.
Switching sections does not reset the state, initially it's only the list of students, so react was trying to access data that doesn't exist.
Switching sections triggers a
{ type: ActionTypes.INIT }
action, which says it's meant to setup the state. Apparently it's an anti-pattern to do anything based on this, but the first actions we always call isSET_SECTION
, so here we reset the state to the initial state (which we should've been doing anyways - the state isn't set up to contain data from multiple sections).This fixes the errors and adds a test for it.