{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/12644","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/12644/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/12644/comments","events_url":"https://api.github.com/repos/facebook/react/issues/12644/events","html_url":"https://github.com/facebook/react/pull/12644","id":315669023,"number":12644,"title":"Add forwardRef DEV warning for prop-types on render function","user":{"login":"bvaughn","id":29597,"avatar_url":"https://avatars0.githubusercontent.com/u/29597?v=4","gravatar_id":"","url":"https://api.github.com/users/bvaughn","html_url":"https://github.com/bvaughn","followers_url":"https://api.github.com/users/bvaughn/followers","following_url":"https://api.github.com/users/bvaughn/following{/other_user}","gists_url":"https://api.github.com/users/bvaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/bvaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvaughn/subscriptions","organizations_url":"https://api.github.com/users/bvaughn/orgs","repos_url":"https://api.github.com/users/bvaughn/repos","events_url":"https://api.github.com/users/bvaughn/events{/privacy}","received_events_url":"https://api.github.com/users/bvaughn/received_events","type":"User","site_admin":false},"labels":[{"id":196858374,"url":"https://api.github.com/repos/facebook/react/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2018-04-18T22:51:11Z","updated_at":"2018-05-30T00:16:07Z","closed_at":"2018-04-18T23:36:31Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/facebook/react/pulls/12644","html_url":"https://github.com/facebook/react/pull/12644","diff_url":"https://github.com/facebook/react/pull/12644.diff","patch_url":"https://github.com/facebook/react/pull/12644.patch"},"body":"Someone at FB recently reported a bug that boiled down to the following:\r\n```js\r\nfunction MyComponent(props, ref) {\r\n  return <p ref={ref}>myProp: {props.myProp}</p>;\r\n}\r\nMyComponent.defaultProps = {\r\n  myProp: \"default\"\r\n};\r\nMyComponent.propTypes = {\r\n  myProp: React.PropTypes.string.isRequired\r\n};\r\n\r\nconst MyWrappedComponent = React.forwardRef(MyComponent);\r\n```\r\nThis _kind of worked_ but, of course, prop-types didn't work.\r\n\r\nWhat they meant to do was:\r\n```js\r\nfunction MyComponent(props) {\r\n  return <p ref={props.forwardedRef}>myProp: {props.myProp}</p>;\r\n}\r\nMyComponent.defaultProps = {\r\n  myProp: \"default\"\r\n};\r\nMyComponent.propTypes = {\r\n  myProp: React.PropTypes.string.isRequired\r\n};\r\n\r\nconst MyWrappedComponent = React.forwardRef((props, ref) => (\r\n  <MyComponent {...props} forwardedRef={ref} />\r\n));\r\n```\r\n\r\nI think it would be nice for us to warn about this in DEV mode. I'm not enamored with this warning message in particular though if someone has better suggestions."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/392989880","html_url":"https://github.com/facebook/react/pull/12644#issuecomment-392989880","issue_url":"https://api.github.com/repos/facebook/react/issues/12644","id":392989880,"user":{"login":"piuccio","id":680284,"avatar_url":"https://avatars0.githubusercontent.com/u/680284?v=4","gravatar_id":"","url":"https://api.github.com/users/piuccio","html_url":"https://github.com/piuccio","followers_url":"https://api.github.com/users/piuccio/followers","following_url":"https://api.github.com/users/piuccio/following{/other_user}","gists_url":"https://api.github.com/users/piuccio/gists{/gist_id}","starred_url":"https://api.github.com/users/piuccio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piuccio/subscriptions","organizations_url":"https://api.github.com/users/piuccio/orgs","repos_url":"https://api.github.com/users/piuccio/repos","events_url":"https://api.github.com/users/piuccio/events{/privacy}","received_events_url":"https://api.github.com/users/piuccio/received_events","type":"User","site_admin":false},"created_at":"2018-05-30T00:16:07Z","updated_at":"2018-05-30T00:16:07Z","author_association":"NONE","body":"Thanks, I've fixed my code. It would also be nice to mention in the documentation that `forwardedRef` is a `PropTypes.object`"}}
{"actor":{"display_login":"piuccio"}}