-
-
Notifications
You must be signed in to change notification settings - Fork 328
how to use sweetalert #1010
-
i read this web http://reactpy.dev/docs/guides/escape-hatches/javascript-components.html#dynamically-loaded-components . but what about for other js libraries like sweetalert . and i also want to use pdf js library later . but my code sweetalert is not working
from fastapi import FastAPI from reactpy.backend.fastapi import configure from reactpy import html,component,web mui = web.module_from_template( # "react@^17.0.0", "react", # "@material-ui/core@4.12.4", # "sweetalert2", "@mui/material", fallback="waiting for my component .....", ) ll = web.module_from_template( "react", "sweetalert2", fallback="waiting for my alert .....", ) Alert = web.export(ll,"Swal") Button = web.export(mui, "Button") @component def ViewButtonEvents(): def showalert(event): Alert.fire({ 'title': 'Error!', 'text': 'Do you want to continue', 'icon': 'error', 'confirmButtonText': 'Cool' }) return html.div( Button( { "color": "primary", "variant": "contained", "onClick": showalert, }, "Click Me!", ), ) app = FastAPI() configure(app,ViewButtonEvents)
Beta Was this translation helpful? Give feedback.
All reactions
module_from_template is scheduled for removal due to random technical bugs. Your issue is likely related.
See #965 for more details
Replies: 3 comments 2 replies
-
I have installed all packages with npm in my project. for material ui it works but sweetalert doesn't
Beta Was this translation helpful? Give feedback.
All reactions
-
@bobwatcherx could it be because showalert(event) accepts an event but one isn't passed for the Button's onClick: showalert?
Beta Was this translation helpful? Give feedback.
All reactions
-
That's definitely possible. My guess is that there's something else going wrong here. module_from_template, unfortunately is pretty finicky, so my guess is that's the issue.
Beta Was this translation helpful? Give feedback.
All reactions
-
👀 1
-
module_from_template is scheduled for removal due to random technical bugs. Your issue is likely related.
See #965 for more details
Beta Was this translation helpful? Give feedback.
All reactions
-
Are there any logs in your browser's dev console or your terminal?
Beta Was this translation helpful? Give feedback.