kcHeaderClass can be updated after initial mount
This commit is contained in:
parent
12f69b593f
commit
1606c2884d
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "keycloakify",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "Keycloak theme generator for Reacts app",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -86,6 +86,7 @@ export const Template = memo((props: TemplateProps) => {
|
||||
useEffect(() => {
|
||||
|
||||
let isUnmounted = false;
|
||||
const cleanups: (() => void)[] = [];
|
||||
|
||||
const toArr = (x: string | readonly string[] | undefined) =>
|
||||
typeof x === "string" ? x.split(" ") : x ?? [];
|
||||
@ -116,15 +117,27 @@ export const Template = memo((props: TemplateProps) => {
|
||||
|
||||
if (props.kcHtmlClass !== undefined) {
|
||||
|
||||
const htmlClassList =
|
||||
document.getElementsByTagName("html")[0]
|
||||
.classList
|
||||
.add(...cx(props.kcHtmlClass).split(" "));
|
||||
.classList;
|
||||
|
||||
const tokens = cx(props.kcHtmlClass).split(" ")
|
||||
|
||||
htmlClassList.add(...tokens);
|
||||
|
||||
cleanups.push(() => htmlClassList.remove(...tokens));
|
||||
|
||||
}
|
||||
|
||||
return () => { isUnmounted = true; };
|
||||
return () => {
|
||||
|
||||
}, []);
|
||||
isUnmounted = true;
|
||||
|
||||
cleanups.forEach(f => f());
|
||||
|
||||
};
|
||||
|
||||
}, [props.kcHeaderClass]);
|
||||
|
||||
if (!isExtraCssLoaded) {
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user