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/[email protected]",
# "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.
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.
-
@bobwatcherx could it be because |
Beta Was this translation helpful? Give feedback.
-
Are there any logs in your browser's dev console or your terminal? |
Beta Was this translation helpful? Give feedback.
module_from_template
is scheduled for removal due to random technical bugs. Your issue is likely related.See #965 for more details