-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: Ionic Routing on currently active IonPage triggers transition and re-rendering, although it is rendered already #22426
Comments
Thanks for the issue. Can you please provide a full application we can use to reproduce the issue? |
@liamdebeasi Thanks for your reply. Yes, I will prepare a full application. |
@phal0r I cannot reproduce this issue. The Routing of Ionic React is in my case very very fast (faster then ionic core routing). |
@BerkeAras In contrast to plain react-router, ionic router does much more work behind the scenes to enable page transitions, i.e. cloning elements, starting animations and so on. This is fine for most use cases, but for my case it is not suitable (and might be somewhat special?). Given I have rendered an IonPage with a map and some markers on this map. Clicking a marker opens an overlay on the same component. So far this is easy to acomplish, but I would like to make the overlay deeplinkable, which means a click on a marker would not change some local state, but trigger a route change with an associated ID, that should be passed as a route param. Is there a way to control this in such a detail? We use such a mechanism for routing, but only changing the optional state object. This does not trigger a rerender, but just passes the new params to the existing IonPage instance, but obviously the optional routing state can not be passed to another a browser by copying the link. Does this clarify my problem? Maybe I should change the title of this issue to be more precise. |
Without a code reproduction it is hard to say why this may be happening. Can you create one and post a link to it here? |
@liamdebeasi It illustrates the difference while routing via route state and route params. |
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. |
Bug Report
Ionic version:
[ ] 4.x
[x] 5.x (particulary Ionic React 5.3.4)
Current behavior:
Given you have a Route element with an optional parameter, i.e.
Then using user events and history.replace() (from react-router package) to toggle between the routes
/locations
andlocations/123
. This is really slow (takes more than 2 seconds) and the chrome profiler indicates, that it always rerenders the component, which is not the expected behaviour.Expected behavior:
Using history.replace() to toggle between routes of the same Route element and thus the same IonPage should not rerender the whole IonPage. It should go through the normal React lifecycle and pass down the new props (which in turn invoke sideeffects and other hooks to update the ui).
Steps to reproduce:
Set up an Ionic React project with a Route, which has an optional parameter. Add 2 buttons, which toggle the active route via history.replace() from react-router.
Performance Diagram
![image](https://user-images.githubusercontent.com/3658211/98012820-d571cf80-1df9-11eb-86e5-58037ada0a3d.png)
Other information:
Ionic info:
The text was updated successfully, but these errors were encountered: