I'm trying to clone a child of the component and add some props to it. But some of the child of this component are with child of their own. And because of that the new props are not cloned to it or to its children.
const component = () => {
const child = componentProp(value, setValue);
if (React.isValidElement(child)) {
return React.cloneElement(child as any, {
onBlur: onFocusChange,
inputRef: searchInput,
});
}
return child;
};
How can I check if the child have children to be sure I can actually add the props to the correct level?