question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: React route navigate back with query string(URL search params) shows flash of default(non-query string) content

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

Not sure if this is specifically an Ionic bug or related to react router, URL search params, or something entirely different - When working with Ionic React and a url search param in the route, navigating back from the route with a search param shows a flash of content for the route if the search param was not provided. For example navigating back from todos?todo=1 briefly shows the contents of todos before popping the page from the stack and navigating back.

https://user-images.githubusercontent.com/14936212/175848414-886ec938-c423-426f-a277-2755beac72fd.mov

Expected Behavior

the page should just pop off the stack w/o showing the flash of non-β€œquery string” content.

Steps to Reproduce

In the repo are three buttons. One goes to a base route and the other two are the base route with a url search param after. Navigate to the base route to see what is rendered when no search param is provided. Then navigate back. Now, navigate to either of the other two routes. You will see a different ui rendered that uses the search param. When navigating back from either of these routes, you will see a flash of the default route content (w/o search params).

Code Reproduction URL

https://github.com/babycourageous/ionic-routing-query-string-bug

Ionic Info

Ionic:

Ionic CLI : 6.18.1 (/Users/renedellefont/.fnm/node-versions/v16.13.1/installation/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/react 6.1.10

Capacitor:

Capacitor CLI : 3.5.1 @capacitor/android : not installed @capacitor/core : 3.5.1 @capacitor/ios : not installed

Utility:

cordova-res : not installed globally native-run : 1.6.0

System:

NodeJS : v16.13.1 (/Users/renedellefont/.fnm/node-versions/v16.13.1/installation/bin/node) npm : 8.1.2 OS : macOS Big Sur

─────────────────────────────────────────────────

 Ionic CLI update available: 6.18.1 β†’ 6.20.1
      Run npm i -g @ionic/cli to update

─────────────────────────────────────────────────

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, Jun 29, 2022

it does appear to be related to the page transition. When starting the transition, the component re-renders. In a regular React Router app (without Ionic), the component does not re-render because there is no exiting transition.

Perhaps there is some improvement we can make to minimizing re-renders, but this issue still would have been a problem. For example, if something in your component caused a re-render mid-transition you would have seen this issue as well.

Glad to hear the issue is resolved. I am going to close this. Thanks for the report!

0reactions
ionitron-bot[bot]commented, Jul 29, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigate to a URL with Query Strings (Search Params) in ...
React Router has a useSearchParams hook to help us read or update the query string of a route that's active, but it doesn't...
Read more >
Why does React Router v6 seem unable to remove query ...
The setSearchParams updater function effectively is "navigate" but for only the queryString portion of the URL. useSearchParams. Note:.
Read more >
Router | RedwoodJS Docs
This is the built-in router for Redwood apps. It takes inspiration from Ruby on Rails, React Router, and Reach Router, but is very...
Read more >
React Router and nested routes - Kevin Farrugia
This layout could be implemented in several ways. export default function App() { return ( <div className="app"> <BrowserRouter> <Routes> <Route path="/Β ...
Read more >
API Reference | React Location - TanStack
The Router component is the root Provider component for the React Location instance and your ... persist, default and manipulate search params for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found