[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-router
breaks theredux-auth-wrapper
package. I need to refactor out that package before continuing.I also need to find a way to implement the legacy
setRouteLeaveHook
which is used byIDEView
and fix some tests which are missing the router provider.Changes:
Updates
react-router
/react-router-dom
from 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.jsx
ElementFromComponent
for 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)} />
.withRouter
similar to the one that used to be exported from thereact-router
package. This is needed to accessparams
,location
, andnavigate
in legacy class components which cannot use hooks../routes.jsx
routes
variable no longer depends on thestore
, as individual routes can access Redux state via context.Main
around theApp
in order to handle legacyonChangeRoute
andonEnter
function. Renders the child content using new<Outlet/>
component.element
instead ofcomponent
.<Route/>
elements to route objects. It should have been possible to keep the<Route/>
syntax and convert it using thecreateRoutesFromElements
utility, 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.js
createBrowserRouter
.navigate
function with no dependencies on other files, but it depends on the./routes
so...not the best.Components:
Link
fromreact-router
toreact-router-dom
.useParams
,useNavigate
, anduseLocation
in function components.props
andpropTypes
.browserHistory.push()
calls withnavigate()
.DashboardView
which are not actually used.Etc:
navigate
function as a property of the global router object.createRedirectWithUsername
function.I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123