Update React Router v5 functions to v6
ManpreetSL opened this issue Β· comments
Summary
React Router DOM package is changing things around in v6. See here for more details.
2 issues that we've identified are:
- The app currently uses the old
useHistory()
hook from the React Router package, but the TS branch has v6 installed, so we'd like to update usages of the old function to its replacement,useNavigate()
wherever possible. - v5's
<Redirect />
component is used, but v6 uses<Navigate />
instead
Approach
- Find usages of
useHistory()
- Import the
useNavigate()
function - Use
useNavigate()
'snavigate
function instead ofuseHistory()
's.push()
- Find usages of the
<Redirect />
component - Replace
<Redirect />
with<Navigate />
Awesome work! Thank you for the time π₯ π π―
As a side note: If you're ready to open a PR already, I don't think it makes much sense to open an issue just prior to the PR. The issues are more for tracking purposes and communication I think.
Awesome work! Thank you for the time π₯ π π―
As a side note: If you're ready to open a PR already, I don't think it makes much sense to open an issue just prior to the PR. The issues are more for tracking purposes and communication I think.
:)
Ahh yeah okay. In the future, I'll just open PRs when it's work I've done like this, then.