S
SolidJS3y ago
avant

Forward props

How to forward props from parent to children without losing reactivity?
3 Replies
lxsmnsyc
lxsmnsyc3y ago
splitProps and spread but really there's a lot of ways depending on what kind of "forwarding" you want
avant
avantOP3y 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
lxsmnsyc3y 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} />

Did you find this page helpful?