Skip to content

Nesting React.functionComponent leads to weirdness - what am I misunderstanding? #640

@njlr

Description

@njlr

This:

let f =
  React.functionComponent (fun () -> Html.text "abc")

let app =
  React.functionComponent
    (fun () ->
      Html.div
        [
          f ()
          Html.text "ijk"
        ]
      )

Looks like this:

Screenshot 2025-01-08 at 19-28-18 Elmish

However, this:

let app =
  React.functionComponent
    (fun () ->
      Html.div
        [
          React.functionComponent (fun () -> Html.text "abc") ()
          Html.text "ijk"
        ]
      )

Looks like this:

Screenshot 2025-01-08 at 19-27-33 Elmish

What are the rules around calling React.functionComponent inside of a component?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions