{"action":"created","issue":{"url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/170","repository_url":"https://api.github.com/repos/davidkpiano/react-redux-form","labels_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/170/comments","events_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/170/events","html_url":"https://github.com/davidkpiano/react-redux-form/issues/170","id":151694175,"number":170,"title":"Field breaks React.Children.only on child component","user":{"login":"MiMaMuh","id":4332418,"avatar_url":"https://avatars.githubusercontent.com/u/4332418?v=3","gravatar_id":"","url":"https://api.github.com/users/MiMaMuh","html_url":"https://github.com/MiMaMuh","followers_url":"https://api.github.com/users/MiMaMuh/followers","following_url":"https://api.github.com/users/MiMaMuh/following{/other_user}","gists_url":"https://api.github.com/users/MiMaMuh/gists{/gist_id}","starred_url":"https://api.github.com/users/MiMaMuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiMaMuh/subscriptions","organizations_url":"https://api.github.com/users/MiMaMuh/orgs","repos_url":"https://api.github.com/users/MiMaMuh/repos","events_url":"https://api.github.com/users/MiMaMuh/events{/privacy}","received_events_url":"https://api.github.com/users/MiMaMuh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/davidkpiano/react-redux-form/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-28T17:03:48Z","updated_at":"2016-04-29T11:04:51Z","closed_at":"2016-04-29T11:04:06Z","body":"Hi, I have a component which uses React.Children.only which itself is wrapped by Field. When it is wrapped the React.Children.only helper always throws an error: \r\n     \"onlyChild must be passed a children with exactly one child\"\r\n\r\n    // fails\r\n    <Field ...>\r\n        <CompUsingChildrenOnly>\r\n            <ChildComp />\r\n        </CompUsingChildrenOnly>\r\n    </Field>\r\n\r\n    // works\r\n    <CompUsingChildrenOnly>\r\n        <ChildComp />\r\n    </CompUsingChildrenOnly>\r\n\r\nAs denoted [here](https://facebook.github.io/react/tips/children-props-type.html), when there is only a single child, this.props.children will be the single child component itself without the array wrapper to save the allocation of an array. \r\n\r\nI think the issue comes from the Field component when it clones the element in [field-component.js](https://github.com/davidkpiano/react-redux-form/blob/master/src/components/field-component.js#L99) using React.Chirldren.map which [always returns](https://facebook.github.io/react/docs/top-level-api.html#react.children.map) an array when a child is there.\r\n\r\nReact.Children.only uses simply [ReactElement.isValidElement(children)](https://github.com/facebook/react/blob/416f315c962c74e057e420b5c24e4e89744174f0/src/isomorphic/children/onlyChild.js#L30) in the background, so this will fail. :)\r\n"},"comment":{"url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/comments/215684996","html_url":"https://github.com/davidkpiano/react-redux-form/issues/170#issuecomment-215684996","issue_url":"https://api.github.com/repos/davidkpiano/react-redux-form/issues/170","id":215684996,"user":{"login":"davidkpiano","id":1093738,"avatar_url":"https://avatars.githubusercontent.com/u/1093738?v=3","gravatar_id":"","url":"https://api.github.com/users/davidkpiano","html_url":"https://github.com/davidkpiano","followers_url":"https://api.github.com/users/davidkpiano/followers","following_url":"https://api.github.com/users/davidkpiano/following{/other_user}","gists_url":"https://api.github.com/users/davidkpiano/gists{/gist_id}","starred_url":"https://api.github.com/users/davidkpiano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidkpiano/subscriptions","organizations_url":"https://api.github.com/users/davidkpiano/orgs","repos_url":"https://api.github.com/users/davidkpiano/repos","events_url":"https://api.github.com/users/davidkpiano/events{/privacy}","received_events_url":"https://api.github.com/users/davidkpiano/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T11:04:51Z","updated_at":"2016-04-29T11:04:51Z","body":"This will be published in the next release: 0.11.6!"}}