[Slot] how to slot a ReactComponent with custom event #3075
Replies: 1 comment
-
It seems that the type problem can't be solved, so I followed Slot's implementation and used cloneElement to do what I needed. export function NewItem({
children,
}: {
// this type define not works
children: ReactElement<{ onValueChange?: (v: string) => void }>
}) {
const dispatch = useDispatch()
return React.cloneElement(children, {
...children.props,
onValueChange: (v: string) => {
children.props?.onValueChange(v)
dispatch({
type: 'add',
name: v
})
}
})
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i have this component, it proxy a Input or Select or any have
onValueChange
compoent, how to fix the type errorBeta Was this translation helpful? Give feedback.
All reactions