So let's say I have a react component that's being rendered like this:
<Form /> In this case, inside Form, this.props.children is undefined.
However, inside render, I have the following:
render: function() { return ( <form> <input name='foo' /> <input name='bar' /> </form> ) } It would be easy to access 'foo' and 'bar' by using the ref keyword. However, this is not flexible/reusable when I have a lot of "children" (that I can't access with this.props.children or React.Children.forEach because they're not "children")
I would like to loop through all the child components that are in render without having to give a ref for each one. (If I give a ref, I would be able to loop through this.refs)
Is this possible?
<Input>components that I have created that have a "valid" state. I want to loop through all of them to determine if the state of the form is valid.