Skip to content

Feliz v3 #26

@Sagensagen

Description

@Sagensagen

Fable 5 and feliz > 3.0 breaks the bindings with the new implementation of react children for react 19

reactElementWithChild and more are removed, but can be written like this:
Source: fable-hub/Feliz#652

module ReactHelper =
  let inline reactElementWithChild (name: string) (child: 'a) =
    React.createElement(
      name, 
      createObj [ ],
      ResizeArray([!!child])
    )

  let inline reactElementWithChildren (name: string) (children: #seq<ReactElement>) =
      React.createElement(
        name, 
        createObj [],
        !!children
      )
  let createElement name (properties: IReactProperty list) : ReactElement =
    match properties |> List.partition (fun (key, _) -> key <> "children") with
    | props, ["children", children] ->
      React.createElement(
        name, 
        createObj props,
        !!children
      )
    | props, _ -> 
      React.createElement(
        name, 
        createObj props,
        ResizeArray()
      )

There might be a bigger migration job, depending on what aim is taken. Recreating the helper functions would be a drop-in solution that should work out of the box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions