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

fix(frontend): keep query param when changing routes #674

Merged
merged 2 commits into from
Jan 3, 2022

Conversation

eh-am
Copy link
Collaborator

@eh-am eh-am commented Jan 3, 2022

Closes #671

This was introduced when we added baseUrl support, where we replaced the barebones Router for BrowserRouter, which broke the react-query-sync library, since it doesn't expose the history object which is handled under the hood.
(see more details at Treora/redux-query-sync#13 (comment))

I spoke with @petethepig and the only reason we did that was to allow passing a basename, which BrowserRouter support.

So I just replaced BrowserRouter for Router to get redux-query-sync working (which is the may issue this PR resolves), and then adds the basename to the history object.

The only thing here is that basename was removed from history from version 5 and onwards (remix-run/history#810), so that may become a problem. But it should be fine for now since we have a simple test that covers the functionality.

Some other thoughts:

  • This is where having the file with typescript would be useful, since we would spot that BrowserRouter does not take a history parameter (https://v5.reactrouter.com/web/api/BrowserRouter) which would probably raise an eyebrown.
  • We need to test the baseURL stuff. Already spoken with @petethepig previously about doing it when we have more time, but honestly, this is the kind of thing we will forget if we don't do it soon.

@@ -30,7 +29,7 @@ try {

ReactDOM.render(
<Provider store={store}>
<BrowserRouter history={history} basename={basename()}>
Copy link
Contributor

Choose a reason for hiding this comment

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

@petethepig wasn't there a reason you felt you needed BrowserRouter instead of Router ?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2022

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
webapp/public/assets/app.js 274.24 KB (-0.04% 🔽) 5.5 s (-0.04% 🔽) 737 ms (+4.63% 🔺) 6.3 s

@codecov
Copy link

codecov bot commented Jan 3, 2022

Codecov Report

Merging #674 (b7e8da6) into main (923fde6) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #674   +/-   ##
=======================================
  Coverage   75.70%   75.70%           
=======================================
  Files          45       45           
  Lines        1592     1592           
  Branches      294      294           
=======================================
  Hits         1205     1205           
  Misses        358      358           
  Partials       29       29           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 923fde6...b7e8da6. Read the comment docs.

@petethepig petethepig merged commit 389019b into main Jan 3, 2022
@petethepig petethepig deleted the fix/changing-view-loses-query-param branch January 3, 2022 21:13
kolesnikovae pushed a commit that referenced this pull request Jan 7, 2022
* add tests for changing routes and maintaining query params

* fix(frontend): rollback to Router to maintain queryParams sync with store
korniltsev pushed a commit that referenced this pull request Jul 18, 2023
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.

Changing views loses query params
3 participants