I'm fairly new to React and I'm creating a simple toolset of form fields which use react-bootstrap. I am using a <Form> component to wrap everything in. The <Form> component will render all the child children, passing a new property.
React.Children.map(this.props.children, (child) => {
return React.cloneElement(child, {
myNewProp: 'hello'
}
});
The problem I have is that the elements which are children which don't have a prop of myNewProp results in a warning Unknown props myNewProp, native HTML and react-bootstrap components. Is there any way to conditionally add props to the child element based upon the type of the component? E.g.
if (child instanceof <nativeHTMLelement>) { ... } else { ... }