Skip to content
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

Update react-router to version 6 #4408

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Update react-router to version 6 #4408

merged 2 commits into from
Jul 31, 2024

Conversation

apata
Copy link
Contributor

@apata apata commented Jul 31, 2024

Changes

Redo of #4384.

It's almost exactly the same as before, except link and navigation search parameters aren't parsed and stringified at the router level, the transforms are applied in custom components.

  • deprecates withRouter HOC
  • explicitly declares all app routes
  • makes navigating to each route use the route definition
  • replaces PlausibleSearchParams with a stringifySearch and parseSearch method, which are applied in the wrapped Link and navigate components AppNavigationLink and useAppNavigate and in QueryContextProvider
    • NB! components are operating with and changing the parsed object
    • NB! setting search param value to false used to be the way to remove the search param, but I wasn't able to keep this behavior, now setting the value to null is the way to do it
  • refactors navigation links and buttons to new navigate API

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@apata apata added the preview label Jul 31, 2024
Copy link

Preview environment👷🏼‍♀️🏗️
PR-4408

@apata apata force-pushed the update-react-router-6 branch 2 times, most recently from dcb1005 to 3bcfabb Compare July 31, 2024 08:55
@apata
Copy link
Contributor Author

apata commented Jul 31, 2024

@ukutaht
Copy link
Contributor

ukutaht commented Jul 31, 2024

Getting this error on the preview deployment:

Screenshot 2024-07-31 at 13 47 41

@apata
Copy link
Contributor Author

apata commented Jul 31, 2024

Getting this error on the preview deployment:

Screenshot 2024-07-31 at 13 47 41

Ah damn, browser difference in URLSearchParams implementation most likely. Getting the same with Safari. Checking

@apata
Copy link
Contributor Author

apata commented Jul 31, 2024

Refactored to one of the methods listed in the url search params polyfill library that we use (https://github.com/jerrybendy/url-search-params-polyfill?tab=readme-ov-file#foreach). That should be safer, even though entries should have been compatible (https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/entries#browser_compatibility). Double checking with other browsers as well.

@apata apata force-pushed the update-react-router-6 branch from c8b831e to 433640a Compare July 31, 2024 12:59
@apata apata merged commit 6c4c078 into master Jul 31, 2024
10 checks passed
@apata apata mentioned this pull request Aug 6, 2024
4 tasks
@apata apata deleted the update-react-router-6 branch January 23, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants