S
SolidJS17mo ago
avant

Forward props

How to forward props from parent to children without losing reactivity?
3 Replies
lxsmnsyc
lxsmnsyc17mo ago
splitProps and spread but really there's a lot of ways depending on what kind of "forwarding" you want
avant
avant17mo ago
I want to make Button component that has all normal button attributes like onClick or class and use that <button> thru Button.tsx
lxsmnsyc
lxsmnsyc17mo ago
so yeah you'd want splitProps, define all of the properties you don't want to pass, then spread it to the child
const [local, rest] = splitProps(props, ['myProp']);

return <button {...rest} />
const [local, rest] = splitProps(props, ['myProp']);

return <button {...rest} />
Want results from more Discord servers?
Add your server
More Posts