SolidJSS
SolidJSβ€’3y agoβ€’
9 replies
valchann

What is props.children really?

I'm trying to make an element that scrolls it's children automatically when mounted. This is what I have currently:
interface AutoScrollProps {
    children: JSXElement
}

function AutoScroll(props: AutoScrollProps) {
    onMount(() => {
        if (props.children instanceof HTMLElement) {
            if (document.body.contains(props.children)) {
                console.log("Element is mounted")
            } else {
                console.log("Element is not mounted")
            }
        }
    })

    return props.children
}

/* ... */

<AutoScroll>
    <div />
</AutoScroll>


It actually prints "Element is not mounted". Does this mean the element that gets mounted in the DOM is a clone of props.children?
Was this page helpful?