Skip to content

Commit c3406c4

Browse files
committed
Fix #3, add test for it
1 parent aaefc70 commit c3406c4

File tree

8 files changed

+2814
-214
lines changed

8 files changed

+2814
-214
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist
2+
coverage

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ example
22
.babelrc
33
form.js
44
README.md
5+
circle.yml
6+
coverage

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## React Validify
2+
[![CircleCI](https://circleci.com/gh/navjobs/validify.svg?style=svg)](https://circleci.com/gh/navjobs/validify)
23

34
### Todo
45

circle.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
machine:
2+
node:
3+
version: 8.2.1

form.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ export default class Form extends React.Component {
5757
renderChildren(children) {
5858
return React.Children.map(children, child => {
5959
if (!child || !child.props) return child;
60+
61+
let children = child.props.children;
6062
if (child.props.children && typeof child.props.children !== 'string')
61-
return this.renderChildren(child.props.children);
63+
children = this.renderChildren(child.props.children);
6264

6365
let { values, errors } = this.state;
6466

6567
if (child.props.name)
6668
return React.cloneElement(child, {
69+
children,
6770
onChange: this.onChange,
6871
onBlur: () => this.onBlur(child.props.name),
6972
error: errors[child.props.name] &&
@@ -78,10 +81,11 @@ export default class Form extends React.Component {
7881

7982
return React.createElement(child.type, {
8083
...otherProps,
84+
children,
8185
onClick: () => this.validate(child.props.onClick),
8286
});
8387
}
84-
return child;
88+
return React.cloneElement(child, { children });
8589
});
8690
}
8791

0 commit comments

Comments
 (0)