-
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: new useIonModal hook for Ionic React renders component outside tree #23516
Comments
Thanks for the issue. Could you reproduce this issue in an Ionic starter app and provide a link to the repo? |
Thanks for the issue! This issue has been labeled as Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed. If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue. For a guide on how to create a good reproduction, see our Contributing Guide. |
Hi Liam Absolutely, here ya go! |
Thanks, and sorry for the delay. I am able to reproduce this behavior. I am checking with the team to see if this the intended behavior. |
No prob at all @liamdebeasi ! Thanks for looking into it. |
Heard back from the other team members and can confirm that overlays should not behave this way. No ETA on a fix yet, but it looks to be similar to what we did in Ionic Vue to ensure overlays are rendered within the correct app context: https://github.com/ionic-team/ionic-framework/blob/main/packages/vue/src/components/IonApp.ts |
Thanks for the update @liamdebeasi ! |
@liamdebeasi has there been any progress/update on this? We're also running into this issue... Thanks! |
After fix #f3e492c VSCode complains:
When I added missing props, error went away. |
@piotr-cz Can you provide a reproduction in an Ionic starter app? |
@liamdebeasi |
Are you getting this error in any other editors? |
Looks to be an issue with Preact: preactjs/preact#2748 I'll keep digging and see if there's anything Ionic can do to work around this. |
@piotr-cz Can you give this dev build a shot and let me know if it fixes the issue?
|
@liamdebeasi I've fixed the issue with hard-wiring paths to react in tsconfig.json as described here: preactjs/preact#2150 (comment) // tsconfig.json
{
"compilerOptions": {
"skipLibCheck": false,
"baseUrl": ".",
"paths": {
"react": ["node_modules/preact/compat"],
"react-dom": ["node_modules/preact/compat"]
}
}
} |
@liamdebeasi |
Thanks for the issue. The original issue here was resolved via f3e492c. The Preact issue has been resolved via #24132, and a fix will be available in an upcoming release of Ionic 6.
|
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
[ ] 6.x
Current behavior:
Just in case this behavior is unintended, the new
useIonModal
hook renders the modal component passed topresent()
outside of the react tree as a sibling of the root node. Because of this, the component used has no access to any app-wide context that wraps the main "App" component that the calling component belongs to.Expected behavior:
Render the component for the modal inside the root react tree.
Steps to reproduce:
Follow the Ionic docs for rendering/presenting a React modal using
useIonModal()
hook.Related code:
Here's a screenshot where you see the component that the hook renders next to the component tree instead of inside it (either as a child or sibling of
<App />
)Other information:
In case this is the intended behavior for the
useIonModal
hook - this may be an opportunity to mention in the docs when deciding whether to use the original<IonModal>
wrapping component or the hook. Perhaps that the hook is meant for modals that don't need access to app-wide data and for those and other complex use-cases continue to use the<IonModal>
component.I would be happy to PR to the docs if needed!
Thanks
Ionic info:
The text was updated successfully, but these errors were encountered: