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
Portal stays visible indefinitely if unmounted immediately after mounting #2606
Comments
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
Facing same issue. Any workarounds? |
Facing the same issue. I tried modifying react-native-paper: 4.7.1 |
Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue. |
Can confirm this is still an issue in the latest version. Our solution is to always render a |
Any case this gets opened again and be fixed? |
why is this closed? this is still an issue |
This issue should be reopened. We've been hit by a similar race condition in
This old PR looks like it might fix this: #2226 |
Still an issue |
Current behaviour
When trying to remove a portal immediately after mounting it, it stays visible indefinitely. See the failing test below.
Expected behaviour
The portal is unmounted and does not stay visible.
Code sample
Here's a minimal failing test case (something equivalent happened to me in more complicated, real world code)
What have you tried
The cause seems to be with the
await
here:react-native-paper/src/components/Portal/PortalConsumer.tsx
Lines 10 to 17 in 975cfa3
The await in
componentDidMount
causes a race condition with the synchronous unmounting:react-native-paper/src/components/Portal/PortalConsumer.tsx
Lines 25 to 29 in 975cfa3
The portal gets (not really) unmounted before being mounted → it stays registered with the portal manager.
One possible fix is to make componentWillUnmount async too:
I'm not sure why the
await Promise.resolve()
was introduced, so I can't tell for sure if it's possible to fix this in a cleaner way.Your Environment
The text was updated successfully, but these errors were encountered: