Skip to content

Should component.mount be part of the public API? #150

Closed
@Rich-Harris

Description

@Rich-Harris

I actually missed this when it was introduced – slaps self on wrist for not paying close enough attention to #91 – but via #149 I just realised we now have a component.mount(node) method.

Obviously we need that for nested components, since mount happens at a separate time to initialisation, but should it be a public method (as opposed to e.g. an undocumented private _mount method)?

My instinct is that it shouldn't, because once you have mount, you kind of have to have unmount (which is different from teardown, but in a slightly confusing way), adding additional code to components that the vast majority of people will never use. And it invites additional onmount and onunmount lifecycle hooks, which muddy the API without that much benefit. Once these things make it into the design, you're basically stuck maintaining them (and explaining the distinction between render/mount and teardown/unmount to confused newcomers) forever.

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