-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support context #207
base: main
Are you sure you want to change the base?
Support context #207
Conversation
omerman
commented
Aug 3, 2022
•
edited
Loading
edited
… only entry point
<a name="0.1.6"></a> ## [0.1.6](sweetalert2/sweetalert2-react-content@v0.1.5...v0.1.6) (2018-03-05) ### Bug Fixes * **ci:** Upgrade `semantic-release` and `[@semantic-release](https://github.com/semantic-release)/git` packages ([bc2862a](sweetalert2@bc2862a))
…weetalert2-react-content"
* chore(package): update dependencies * chore(package): Update more dependencies * chore(package): Downgrade webpack-serve back down to v0.1.5 and add to package.greenkeeper.ignore
…s are React elements
@omerman Thank you for your interest in solving this issue (#192)! I don't want to merge this however because of some limitations it has:
Also, not exactly a limitation but an ergonomic thing: you would have to explicitly specify which context(s) you want to provide, when I think we can assume users just want whatever contexts are provided to the component from which the alert is fired. I believe a more complete solution is possible, even one that covers # 3 and the ergonomic issue. |
At first glance I tried seeking a solution that will use the App context, such as portals, but there wasn't a quick one to write. |
@zenflow I've added support for Portal. The code itself is not ideal, but it works as expected.
|
@ zenflow 😢 ? |
@zenflow In the meantime I'm using my fork, but I really think you should consider approving this pr. Please let me know what you think |
Hi @omerman sorry for the long delay. I'll have a look at this on Sunday. Just two notes for now:
|
@zenflow I think that 99% of the usecase will not need to set up different Swal behaviors, meaning it will probably be placed under the app providers and be expected to work under those contexts. I did fiddle around with the concept of placing a Swal provider under different tree levels of react dom, exposing hooks and holding a token that will be used when Launching a popup, but I decided it's a small edge case. Having said that, If we decide to support this case, I believe it can be done without breaking the current behavior. It could have the same api and if not supplied with a Swal hook's key while launcing a pop up, we will take the closest to Root node Swal context. Hope you understood my explanation 😅 |
And regarding your tests, If you want I'll add you as a collaborator on my fork and you can add the files, or send it here as a comment and I'll run it |
ec4c74b
to
e5a05db
Compare
7f3b0a1
to
59a1369
Compare