Recursive surface component?

@msaraiva 's example can be simplified to:

defmodule Tree do
  ...
    
  @doc "The root node"
  prop node, :map
  
  def render(assigns) do
    ~H"""
    <div>
      {{ @node.name }}
      <div :for={{ child <- @node.children }}>
        {{ render(%{node: child}) }}
      </div>
    </div>
    """
  end
end

Although the component cannot be recursively defined, the render/1 method can call itself recursively, with a made up assigns. This method works as long as the component has no state; because state-less component is basically just a render/1 function with maybe some pure function helpers.

I don’t know how to achieve the equivalent of recursive stateful component though. I don’t have a usage case so far.