{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/3279","labels_url":"https://api.github.com/repos/facebook/react/issues/3279/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/3279/comments","events_url":"https://api.github.com/repos/facebook/react/issues/3279/events","html_url":"https://github.com/facebook/react/issues/3279","id":59196867,"number":3279,"title":"componentDidReceiveProps Please","user":{"login":"iammerrick","id":109635,"avatar_url":"https://avatars.githubusercontent.com/u/109635?v=3","gravatar_id":"","url":"https://api.github.com/users/iammerrick","html_url":"https://github.com/iammerrick","followers_url":"https://api.github.com/users/iammerrick/followers","following_url":"https://api.github.com/users/iammerrick/following{/other_user}","gists_url":"https://api.github.com/users/iammerrick/gists{/gist_id}","starred_url":"https://api.github.com/users/iammerrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iammerrick/subscriptions","organizations_url":"https://api.github.com/users/iammerrick/orgs","repos_url":"https://api.github.com/users/iammerrick/repos","events_url":"https://api.github.com/users/iammerrick/events{/privacy}","received_events_url":"https://api.github.com/users/iammerrick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-02-27T06:34:05Z","updated_at":"2015-03-20T01:29:50Z","closed_at":null,"body":"I would like to humbly request a componentDidReceiveProps hook, often times I would like to do something on both componentWillMount and componentWillReceiveProps, but because `this.props` hasn't been set yet I am forced to pass props around instead of reading directly from `this.props`.\r\n\r\n## Before New Hook\r\n\r\n```javascript\r\ncomponentWillMount() {\r\n  this.setup(this.props.id);\r\n}\r\n\r\ncomponentWillReceiveProps(next) {\r\n  this.setup(next.id);\r\n}\r\n\r\nsetup(id) {\r\n  UserActions.load(id);\r\n}\r\n```\r\n\r\n## After New Hook\r\n\r\n```javascript\r\ncomponentWillMount() {\r\n  this.setup();\r\n}\r\n\r\ncomponentDidReceiveProps() {\r\n  this.setup();\r\n}\r\n\r\nsetup() {\r\n  UserActions.load(this.props.id);\r\n}\r\n```\r\n\r\nIn this simple example it may seem like a small thing, but often times the passing of props runs deep and instead of conveniently referencing this.props one is forced to plumb the props throughout the component.\r\n\r\nPlease consider adding `componentDidReceiveProps` as a hook to leverage the same code that is leveraged in componentWillMount without forcing both to plumb props throughout the component."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/83841651","html_url":"https://github.com/facebook/react/issues/3279#issuecomment-83841651","issue_url":"https://api.github.com/repos/facebook/react/issues/3279","id":83841651,"user":{"login":"dandelany","id":734221,"avatar_url":"https://avatars.githubusercontent.com/u/734221?v=3","gravatar_id":"","url":"https://api.github.com/users/dandelany","html_url":"https://github.com/dandelany","followers_url":"https://api.github.com/users/dandelany/followers","following_url":"https://api.github.com/users/dandelany/following{/other_user}","gists_url":"https://api.github.com/users/dandelany/gists{/gist_id}","starred_url":"https://api.github.com/users/dandelany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandelany/subscriptions","organizations_url":"https://api.github.com/users/dandelany/orgs","repos_url":"https://api.github.com/users/dandelany/repos","events_url":"https://api.github.com/users/dandelany/events{/privacy}","received_events_url":"https://api.github.com/users/dandelany/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T01:29:50Z","updated_at":"2015-03-20T01:29:50Z","body":"+1, I am also finding myself passing around props a lot. Similar to @insin above I was using default params for awhile:\r\n\r\n```\r\nsetup(props = this.props) {\r\n  doSomething(props);\r\n}\r\n```\r\n\r\nBut decided it was an anti-pattern due to the subtle bugs it can cause if you forget to pass newProps.\r\n\r\n"}}