Closed
Description
Current Situation
Right now, if an element starts out as a component, it can't be converted to a component later. For example,
from idom import component, html
@component
def First():
if condition:
return html.div()
else:
return Second()
@component
def Second():
...
This will result in either of the following errors:
- https://github.com/idom-team/idom/blob/53300b22772a2d308860f29147d509a63909cbf3/src/idom/core/layout.py#L490
- https://github.com/idom-team/idom/blob/53300b22772a2d308860f29147d509a63909cbf3/src/idom/core/layout.py#L529
Initially I introduced those errors because I imagined that this scenario would be uncommon or that if it did one would want to avoid changing from a standard element to a component. The simplicity of the case above though demonstrates how common and useful this case might be.
Proposed Actions
All the above described usage. The logic inside the layout is getting complex enough that it may warrant refactoring at some point to make it easier to understand. Right now there's a lot of mutation that goes on which is hard to follow.
Work Items
No response