Skip to content

Commit d3c4273

Browse files
authored
check against hooks inside of root component (#5971)
1 parent 81a1b2f commit d3c4273

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

reflex/compiler/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def create_document_root(
417417
*maybe_head_components,
418418
*always_head_components,
419419
]
420-
return Html.create(
420+
html_component = Html.create(
421421
Head.create(*head_components),
422422
Body.create(
423423
Var("children"),
@@ -427,6 +427,11 @@ def create_document_root(
427427
lang=html_lang or "en",
428428
custom_attrs=html_custom_attrs or {},
429429
)
430+
hooks = html_component._get_all_hooks()
431+
if hooks:
432+
msg = "You cannot use stateful components or hooks in the document root. Check your head components."
433+
raise ValueError(msg)
434+
return html_component
430435

431436

432437
def create_theme(style: ComponentStyle) -> dict:

0 commit comments

Comments
 (0)