You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are instances where the user may genuinely want to pretend like a component doesn't exist (ex. Django IDOM conditional rendering based on authentication). Currently, exceptions are generated if a component returns NoneType.
2021-11-21T13:15:57-0800 | ERROR | Failed to render homepage(1408449473488, websocket=<django_idom.websocket_consumer.IdomAsyncWebsocketConsumer object at 0x00000147EB0C4B80>)
Traceback (most recent call last):
File "C:\Users\Username\Repositories\Conreq\.venv\lib\site-packages\idom\core\layout.py", line 201, in _render_component
self._render_model(old_state, new_state, raw_model)
File "C:\Users\Username\Repositories\Conreq\.venv\lib\site-packages\idom\core\layout.py", line 236, in _render_model
new_state.model.current = {"tagName": raw_model["tagName"]}
TypeError: 'NoneType' object is not subscriptable
Iterables
In many situations, not allowing for iterable return type increases the the DOM depth can be unnecessarily. For example, in my circumstances, my components are almost always returning nothing but several other components. I need to add an unnecessary div wrapper to get the component rendering working. From Django IDOM's side, this makes for the top-level component div, and then a second wrapper div directly below it.
2021-11-21T13:18:52-0800 | ERROR | Failed to render homepage(1628060950176, websocket=<django_idom.websocket_consumer.IdomAsyncWebsocketConsumer object at 0x0000017B0FF1B6A0>)
Traceback (most recent call last):
File "C:\Users\Username\Repositories\Conreq\.venv\lib\site-packages\idom\core\layout.py", line 201, in _render_component
self._render_model(old_state, new_state, raw_model)
File "C:\Users\Username\Repositories\Conreq\.venv\lib\site-packages\idom\core\layout.py", line 236, in _render_model
new_state.model.current = {"tagName": raw_model["tagName"]}
TypeError: list indices must be integers or slices, not str
Proposed Changes
Allow for NoneType and Iterable return types in components.
Implementation Details
Modify idom.core.layout to detect these situations and handle them differently than the standard VDOM return type.
The text was updated successfully, but these errors were encountered:
This one's definitely on my radar. Though there's some reasons returning lists and tuples directly isn't a great idea. React allows for something called fragments (<>...</>). In IDOM we could do something similar with html._(...).
Current Situation
NoneType
There are instances where the user may genuinely want to pretend like a component doesn't exist (ex. Django IDOM conditional rendering based on authentication). Currently, exceptions are generated if a component returns NoneType.
Iterables
In many situations, not allowing for iterable return type increases the the DOM depth can be unnecessarily. For example, in my circumstances, my components are almost always returning nothing but several other components. I need to add an unnecessary div wrapper to get the component rendering working. From Django IDOM's side, this makes for the top-level component div, and then a second wrapper div directly below it.

Proposed Changes
Allow for NoneType and Iterable return types in components.
Implementation Details
Modify
idom.core.layout
to detect these situations and handle them differently than the standard VDOM return type.The text was updated successfully, but these errors were encountered: