Props di Solid adalah reactive proxy — jangan di-destructure karena akan kehilangan reactivity!
Menggunakan Props
function Greeting(props) {
return <h2>Halo, {props.nama}!</h2>
}
// Penggunaan
<Greeting nama="Andi" />
Jangan Destructure!
// ❌ SALAH - kehilangan reactivity
function Greeting({ nama }) {
return <h2>Halo, {nama}!</h2>
}
// ✅ BENAR
function Greeting(props) {
return <h2>Halo, {props.nama}!</h2>
}
mergeProps dan splitProps
import { mergeProps, splitProps } from "solid-js"
// Default props
const merged = mergeProps({ color: "blue" }, props)
// Split props
const [local, others] = splitProps(props, ["class", "style"])