[WIP] Upgrade react-router from "^3.2.6" to "^6.8.1"
#2135
Closed
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.
Fixes #875
My work on this is PR paused because I've gotten far enough to see that updating
react-routerbreaks theredux-auth-wrapperpackage. I need to refactor out that package before continuing.I also need to find a way to implement the legacy
setRouteLeaveHookwhich is used byIDEViewand fix some tests which are missing the router provider.Changes:
Updates
react-router/react-router-domfrom version 3.2.6 to current version 6.8.1. This is up three major versions so there are a lot of changes. It's very easy to update function components but a real pain to update class components.Setup/Configuration:
router-compatibility.jsxElementFromComponentfor backwards compatibility with components that are created inline and therefore difficult to instantiate via JSX. Can now convert fromcomponent={userIsAuthenticated(AccountView)}toelement: <ElementFromComponent component={userIsAuthenticated(AccountView)} />.withRoutersimilar to the one that used to be exported from thereact-routerpackage. This is needed to accessparams,location, andnavigatein legacy class components which cannot use hooks../routes.jsxroutesvariable no longer depends on thestore, as individual routes can access Redux state via context.Mainaround theAppin order to handle legacyonChangeRouteandonEnterfunction. Renders the child content using new<Outlet/>component.elementinstead ofcomponent.<Route/>elements to route objects. It should have been possible to keep the<Route/>syntax and convert it using thecreateRoutesFromElementsutility, however this did not work due to the hot reloader package that we are using. Relevant discussion See also Improper setup of obsolete packagereact-hot-loader#2134./router.jscreateBrowserRouter.navigatefunction with no dependencies on other files, but it depends on the./routesso...not the best.Components:
Linkfromreact-routertoreact-router-dom.useParams,useNavigate, anduseLocationin function components.propsandpropTypes.browserHistory.push()calls withnavigate().DashboardViewwhich are not actually used.Etc:
navigatefunction as a property of the global router object.createRedirectWithUsernamefunction.I have verified that this pull request:
npm run lint)npm run test)developbranch.Fixes #123