children() helper menyelesaikan dan melacak children secara reactive.
Masalah
Di Solid, props.children bisa berupa function, array, atau single element. Akses langsung bisa bermasalah.
children() Helper
import { children } from "solid-js"
function Wrapper(props) {
const resolved = children(() => props.children)
createEffect(() => {
// resolved() mengembalikan array elemen yang sudah di-resolve
console.log("Children:", resolved())
})
return <div>{resolved()}</div>
}
Gunakan children() saat kamu perlu memanipulasi atau mengiterasi children.