Skip to main content

user_defined_render_fn

Function user_defined_render_fn 

Source
pub fn user_defined_render_fn(
    def: &ComponentDef,
    data: &ComponentDataModel,
    component_map: &ComponentMap,
) -> ResultStyledDomRenderDomError
Expand description

Default render function for user-defined (JSON-imported) components.

Interprets the ComponentDef structure generically:

  1. Creates a wrapper <div> with the component’s CSS class
  2. For each data field, renders content based on type:
    • String fields → text node with current value
    • Bool fields → conditional display
    • StyledDom fields → embeds the child DOM subtree
    • StructRef/EnumRef → recursively renders sub-components if found in ComponentMap
    • Other scalar fields → text display of the value
  3. Applies the component’s scoped CSS