Skip to content

voidEl breaks with: $ELEMENT is a void element tag and must neither have children nor use dangerouslySetInnerHTML. #243

Open
@kentcb

Description

@kentcb

We recently upgraded from Fable.React 5.4.0 to 9.4.0, a rather large jump to be sure. An issue we now have is that rendering an element using either voidEl (either directly or indirectly via Fable.React.Standard) results in an error:

Uncaught Error: br is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.

Curiously, if I copy voidEl into my component and use that copy then it works. Digging a little deeper, I can see that it comes down to what JS is generated for each case. The working case generates:

react.createElement("br", {})

And the non-working case:

react.createElement("br", {}, [])

I assume the trailing empty array is triggering the error diagnostic because it is being interpreted as an attempt to assign zero children to the br, as opposed to not even attempting to assign any children.

I've got a feeling it has something to do with the ParamListAttribute on the children parameter to createElement, but not entirely sure why it manifests in one scenario and not the other.

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