I created a component called labeledElement , which basically just generates
<label {...props}> <span class="label">{props.label}</span> {props.children} </label>
However, this is a problem if the children contain multiple inputs or buttons, as tags spread clicks and focus on children. In this scenario, I would like to use a div instead of a label.
Is it possible in my render method to analyze child elements, see if there are more than one child matching the 'button input textarea select' , and depending on this output a label or div?
I have some thoughts on how to hack it together, but all these requirements require connecting up to componentDidMount , checking the DOM, and setting up a state that seems like a certain wrong way of doing things.
source share