Skip to content

Commit afb7110

Browse files
committed
recusrively go through children and return regular components
1 parent eceb70d commit afb7110

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

form.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ export default class Form extends React.Component {
5151
this.setState({ values });
5252
}
5353

54-
renderChildren() {
55-
return React.Children.map(this.props.children, child => {
54+
renderChildren(children) {
55+
return React.Children.map(children, child => {
5656
if (!child || !child.props) return child;
57+
if (child.children) return this.renderChildren(children);
58+
5759
let { values, errors } = this.state;
5860

5961
if (child.props.name)
@@ -75,11 +77,12 @@ export default class Form extends React.Component {
7577
onClick: () => this.validate(child.props.onClick),
7678
});
7779
}
80+
return child;
7881
});
7982
}
8083

8184
render() {
8285
let { children, rules, ...props } = this.props;
83-
return <div {...props}>{this.renderChildren()}</div>;
86+
return <div {...props}>{this.renderChildren(children)}</div>;
8487
}
8588
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-validify",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Form validation made easy",
55
"main": "dist/form.js",
66
"directories": {

0 commit comments

Comments
 (0)