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: Route components not being unmounted correctly

See original GitHub issue

Bug Report

Ionic version:

[x] 5.x

Current behavior: Route components aren’t unmounted correctly after navigation and preserves the state of components.

Expected behavior: It should be a “clean slate” when re-entering route components similarly to how it works with other react components.

Steps to reproduce: I have linked a code sand box that shows the issue. Each route has a stateful component (using xstate) and on browsing between the two routes the state is preserved between the routes. Note this doesn’t happen with react’s setState but does happen in this case due to the use of useRef. As noted on the react docs, useRef should only last for the lifetime of the component which suggests that the components aren’t being unmounted.

Related code:

https://codesandbox.io/s/ionic-react-router-h9v54

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
allforabitcommented, Jun 17, 2020

I tried setting up a fresh sandbox but ionic and code sandbox don’t seem to be playing together for some reason: https://codesandbox.io/s/ionic-smoke-test-62vvv I’ll try again in a day or two.

0reactions
ionitron-bot[bot]commented, Jul 18, 2020

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

react router not unmounting previous content when route is ...
You have a couple options: Move the key to the correct component. It is rather irrelevant on the Route component. Move the key...
Read more >
Handling Mounting And Unmounting Of Navigation Routes In ...
Let's look at how to mount and unmount navigation stack based on a met ... Custom components in React Native (how to create...
Read more >
Avoid React state update warnings on unmounted components
React raising a warning when you try to perform a state update on an unmounted component. React setState is used to update the...
Read more >
Reconciliation - React
Just to be clear, rerender in this context means calling render for all components, it doesn't mean React will unmount and remount them....
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
When you do, you'll be able to toggle the details without an error. No warning when toggling, 6. When you unmount, the component...
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