Skip to content

Upgrade react-router from v4 to v5 and begin using hooks #2295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 2, 2023

Conversation

lindapaiste
Copy link
Collaborator

Related issue #857

This is step 2 and should be merged after #2294

Upgrading react-router from v4 to v5 is a non-breaking change so all that is strictly required is changing the package versions.

v5.1.0 introduces React hooks useLocation, useParams, useHistory, etc. These are now the preferred way to access location, params, and history rather than via props (or via a global variable, in the case of history).

As v5.x is backwards-compatible, existing code using this.props.location will still work. I have not made changes to any class components in this PR. I have only used the hooks in existing function components where it is trivial to do so.

Note: In v6 the hooks will be the only way to access the router state. Though we can create our own backwards-compatibility for class components by creating HOCs.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@lindapaiste lindapaiste requested a review from raclim July 15, 2023 02:22
Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@raclim raclim merged commit 2da277c into processing:develop Aug 2, 2023
@lindapaiste lindapaiste deleted the chore/react-router-v5 branch August 8, 2023 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants