Allow NoneType and Iterable returns within components #538
Labels
priority-2-moderate
Should be resolved on a reasonable timeline.
type-feature
About new capabilities
Milestone
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.
![image](https://user-images.githubusercontent.com/16909269/142779382-00a41d49-cd6c-4c6f-a77b-6e1fb1aa9198.png)
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: