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: overlays reusing inner component instance even after dismissing

See original GitHub issue

Bug Report

Ionic version:

[x] 5.6.3

Current behavior:

In my IonModal, I define useState hooks to manage code while the modal is displayed on the page. This works great when the modal is displayed, however, when I close the modal and then reopen, the state variables that were modified during the last time the modal was opened, still show instead of the useState hooks resetting back to their initial state.

Video demo: https://streamable.com/cd965g

Expected behavior:

I expect to have the modal reset its state every time I reopen a modal.

Steps to reproduce:

CodeSandbox for reproduction: https://codesandbox.io/s/cool-bash-z8f5j?file=/src/pages/Tab1.tsx

Steps to recreate using the link above:

  1. On Tab One, click “Show Modal”
  2. On the modal, observe the text displaying “init”
  3. Click the button “Change Modal State”
  4. On the modal, observe the text now displaying “changed state!”
  5. Close the modal by clicking outside the modal or the close button in the top right
  6. Reopen the modal by clicking “Show Modal”
  7. Observe that the text on the page is NOT “init” but instead the “changed state!” text from the last time we used the modal

NOTE: if you switch between tabs and then back to Tab One and click “Show Modal” the state finally resets.

This behavior is different from an older version of Ionic React I had been using recently. Is this the new intended behavior or should the state indeed be resetting upon hiding the modal? Logically, since the modal is being removed from the DOM I’d expect the state to reset…right?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
uncvrdcommented, Apr 5, 2021

Hey Liam! Glad you were able to get it to work 😃 Yes the dev build looks like it resolves the problem

0reactions
ionitron-bot[bot]commented, May 6, 2021

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

bug: overlays reusing inner component instance even after ...
In my IonModal , I define useState hooks to manage code while the modal is displayed on the page. This works great when...
Read more >
Managing State for Overlay Dismissed Components in Vuetify
I'm building out a vuetify/nuxt frontend for the first time, and I've moved my v-navigation-drawer component out of the default.vue layout, and ...
Read more >
Create overlays in your prototypes - Figma Help Center
You create an overlay when you define the interaction of a connection. Overlays can be triggered from any object, layer, group or frame....
Read more >
Angular Development #10 - RouteReuseStrategy - Intertech
RouteReuseStrategy is powerful tool to customize Angular and greatly improve the user experience. Learn how to use it and the pitfalls to ...
Read more >
Using the Vue loading overlay plugin in your Vue apps
After importing it in the component, the loader component can be used by just placing it inside the container you want it to...
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