[Slot] how to slot a ReactComponent with custom event #3075
Unanswered
shaddollxz
asked this question in
Help
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
-
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