Skip to content

Commit ffdba7e

Browse files
committed
test no render for component without state
1 parent 6a50d56 commit ffdba7e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_core/test_layout.py

+24
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,27 @@ def Inner(key):
471471
outer_hook.latest.schedule_render()
472472
await layout.render()
473473
assert old_inner_hook is inner_hook.latest
474+
475+
476+
async def test_log_warning_on_attempt_to_render_component_not_in_layout(caplog):
477+
@idom.component
478+
def SomeComponent():
479+
return idom.html.div()
480+
481+
component_in_layout = SomeComponent()
482+
component_not_in_layout = SomeComponent()
483+
484+
with idom.Layout(component_in_layout) as layout:
485+
await layout.render()
486+
487+
# try to update a component instance not in layout
488+
layout.update(component_not_in_layout)
489+
# update this too so the next render doesn't hang forever
490+
layout.update(component_in_layout)
491+
492+
await layout.render()
493+
494+
assert (
495+
next(iter(caplog.records)).message
496+
== f"Did not render component - {component_not_in_layout} already unmounted or does not belong to this layout"
497+
)

0 commit comments

Comments
 (0)