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:
It actually prints "Element is not mounted". Does this mean the element that gets mounted in the DOM is a clone of props.children?
6 Replies
console log props to see
in your case it’s probably a getter, so each time you read from it you run its function, and create new html elements
this is why
children
helper exists, to resolve the children, and gives you signal that you can access multiple timesalright, i'll try that
doesn't seem to make a difference
https://stackblitz.com/edit/solid-vite-xvfamp?file=src%2Findex.tsx
you’re still reading from props.children in multiple places
oh yeah!
now it works! thank you so much!
Children can contain JSX.Element (which on the server is an object { t: template, ... } and on the client a HTMLElement or false or null), an Array of JSX.Elements. FlowComponents like <For> can have Functions that return JSX.Element or JSX.Element[] instead as children.