Permalink
Browse files

Fix #3, add test for it

  • Loading branch information...
zackify committed Aug 8, 2017
1 parent aaefc70 commit c3406c4720c1eacba7269e2810e1aae8612224b8
Showing with 2,814 additions and 214 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 .npmignore
  3. +1 −0 README.md
  4. +3 −0 circle.yml
  5. +6 −2 form.js
  6. +2,757 −209 package-lock.json
  7. +25 −3 package.json
  8. +19 −0 tests/children.js
View
@@ -1 +1,2 @@
dist
coverage
View
@@ -2,3 +2,5 @@ example
.babelrc
form.js
README.md
circle.yml
coverage
View
@@ -1,4 +1,5 @@
## React Validify
[![CircleCI](https://circleci.com/gh/navjobs/validify.svg?style=svg)](https://circleci.com/gh/navjobs/validify)
### Todo
View
@@ -0,0 +1,3 @@
machine:
node:
version: 8.2.1
View
@@ -57,13 +57,16 @@ export default class Form extends React.Component {
renderChildren(children) {
return React.Children.map(children, child => {
if (!child || !child.props) return child;
let children = child.props.children;
if (child.props.children && typeof child.props.children !== 'string')
return this.renderChildren(child.props.children);
children = this.renderChildren(child.props.children);
let { values, errors } = this.state;
if (child.props.name)
return React.cloneElement(child, {
children,
onChange: this.onChange,
onBlur: () => this.onBlur(child.props.name),
error: errors[child.props.name] &&
@@ -78,10 +81,11 @@ export default class Form extends React.Component {
return React.createElement(child.type, {
...otherProps,
children,
onClick: () => this.validate(child.props.onClick),
});
}
return child;
return React.cloneElement(child, { children });
});
}
Oops, something went wrong.

0 comments on commit c3406c4

Please sign in to comment.