Skip to content

Component remounted when mapping mkDOM #8

@echaozh

Description

@echaozh

Code: map (DOM.div {} <<< singleton) [DOM.p {} (), DOM.p {} ()] produces:
Error: Invariant Violation: mountComponent(.0.0.1.1, ...): Can only mount an unmounted component. Make sure to avoid storing components between renders or reusing a single component instance in multiple places.

Code: map (DOM.div {} <<< singleton <<< DOM.text) ["a", "b"] oddly produces 2 bs, instead of 1 a before 1 b.

I'm not very familiar with reactjs, but my understanding is that the {} is shared by all the DOM nodes thus created, and this sharing is not allowed. I've tried cloning the {}, and it works.

My proposal is to add a group of mkDOM wrappers cloning the props before constructing the nodes. They may get their own module namespace. Shallow cloning should be OK as the reactive fields inside the props observed by the React.DOM constructors are still shared. Also, cloning is not necessary if mkDOM is not partially applied to props, so the non-cloning wrappers should be kept as default.

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