Skip to content

bind:this does not work in component that is manually instantiated in onMount #6760

@duydang2311

Description

@duydang2311

Describe the bug

If I attempt to create a child component by client-side API in onMount of the parent component, the variable that I binded the element reference to in that child will be undefined.
So, the workaround is not to create it immediately when onMount is called, but after an amount of time (e.g for 20ms or await tick()).

Reproduction

https://svelte.dev/repl/5c59fe6aa6354b03aea62c445836f2b1?version=3.42.6

Logs

No response

System Info

System: OS: Windows 10 10.0.22000 CPU: (8) x64 Intel(R) Core(TM) i3-10100F CPU @ 3.60GHz Memory: 9.81 GB / 15.94 GB Binaries: Node: 16.9.1 - C:\Program Files\nodejs\node.EXE npm: 7.21.1 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22000.120.0), Chromium (93.0.961.52) Internet Explorer: 11.0.22000.120

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions