PublicDataWorks / complaint-manager

Apache License 2.0
4 stars 0 forks source link

Update history package #507

Open rnair-tw opened 4 months ago

rnair-tw commented 4 months ago

User Story

As a developer I want to update the history package So that I can use the stable release of history version 5

As part of #102 we did a spike to understand how to upgrade the history package. Our concern is that we are using version 4.10.1, however there are breaking changes in version 5.0.0 because relative routes are no longer supported.This card is to do the actual update itself. See findings from the spike in comments section of #102.

Definition of Done

History package is updated.

heliofreitastw commented 2 weeks ago

With the current project situation we will not be able to update the history package.

When the package is updated, we face the following error: Could not find router reducer in state tree, it must be mounted under "router”.

This error is happening for several routes in the app. For example, clicking on the menu of the top right corner and clicking to open the data datasboard page causes the error to happen (the data dashboard page does not open). The same behavior happens when a click to open different pages happens.

Going through the links provided in the spike card #102. We learned that we already have the implementation suggested in this link in your codebase. Also, another answer from the same link says that history version 5.0.0 is only compatible with react-router-dom version 6 or above. Currently in the project we use version 5.1.0 for react-router-dom.

I found this link on upgrading react-router-dom.

heliofreitastw commented 1 week ago

While working on this card, @etessema1 and I learned more about the issue. The history@5 or newer needs the package react-router@v6 to work (this package is the core of react-router-dom which is the name of the package we use). So, some code changes are necessary to make them compatible. This link has more information about this. In summary, to be able to use the newer version of the packages we need to update, we would need to turn some class components into functional components. Another problem we found was with a different package that currently is in use called connected-react-router. Currently this package only works with version 5 of react-router. So we would need to find a solution for this issue.