Load scripts after component rendered #470

This commit is contained in:
Joseph Garrone
2024-05-07 20:04:27 +02:00
parent b61f442a15
commit a887844a37
4 changed files with 44 additions and 34 deletions

View File

@ -26,7 +26,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
const { msg, msgStr, changeLocale, labelBySupportedLanguageTag, currentLanguageTag } = i18n;
const { realm, locale, auth, url, message, isAppInitiatedAction, authenticationSession } = kcContext;
const { realm, locale, auth, url, message, isAppInitiatedAction, authenticationSession, scripts } = kcContext;
const { isReady } = usePrepareTemplate({
"styles": !doUseDefaultCss
@ -64,7 +64,17 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
].join("\n")
}
}
])
]),
...scripts.map(
script =>
({
"isModule": false,
"source": {
"type": "url",
"src": script
}
} as const)
)
],
"htmlClassName": getClassName("kcHtmlClass"),
"bodyClassName": getClassName("kcBodyClass"),