Skip to content

Commit 98d92e1

Browse files
committed
conditional render none should not reset state for sibling components
1 parent 78b5651 commit 98d92e1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/py/reactpy/tests/test_core/test_layout.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,3 +1320,26 @@ def Child():
13201320
{"tagName": "div", "children": [{"tagName": "", "children": []}]}
13211321
],
13221322
}
1323+
1324+
1325+
async def test_conditionally_render_none_does_not_trigger_state_change_in_siblings():
1326+
toggle_condition = Ref()
1327+
effect_run_count = Ref(0)
1328+
1329+
@component
1330+
def Root():
1331+
condition, toggle_condition.current = use_toggle(True)
1332+
return html.div("text" if condition else None, Child())
1333+
1334+
@component
1335+
def Child():
1336+
@reactpy.use_effect
1337+
def effect():
1338+
effect_run_count.current += 1
1339+
1340+
async with layout_runner(Layout(Root())) as runner:
1341+
await runner.render()
1342+
poll(lambda: effect_run_count.current).until_equals(1)
1343+
toggle_condition.current()
1344+
await runner.render()
1345+
assert effect_run_count.current == 1

0 commit comments

Comments
 (0)