[SIG-2358] User overview page infinite loop on navigation #671
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.
User overview page infinite loop on navigation
The Issue
Navigating from the users overview page to a user detail page, after a user's data was posted before that navigation occurred, lead the application into an endless loop, causing errors and freezing the page.
The Problem
The cause was the state that was pushed onto the history stack. Removing it solved the problem. It is, however, unclear why providing a value for a history item's state lead to an endless loop. I looked into issues concerning
redux
,react-router-dom
andconnected-react-router
, but I couldn't find the problem.The solution
The reason that a value for a history item's state was needed, was that the filter selection needed to be retained when navigating from the overview page to a detail page and back again.
In order to keep that functionality, the
settings
module has been changed so that it keeps state in a reducer and passes that state into its child component by using a context provider.The values for the context are updated by the overview page through a
dispatch
function that is also provided by the context. This way, all underlying pages in thesettings
module can make use of the state and update it accordingly.