{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/redux/issues/702","labels_url":"https://api.github.com/repos/rackt/redux/issues/702/labels{/name}","comments_url":"https://api.github.com/repos/rackt/redux/issues/702/comments","events_url":"https://api.github.com/repos/rackt/redux/issues/702/events","html_url":"https://github.com/rackt/redux/issues/702","id":105888583,"number":702,"title":"Question on using componentDidMount() with react-router","user":{"login":"tkiethanom","id":1057146,"avatar_url":"https://avatars.githubusercontent.com/u/1057146?v=3","gravatar_id":"","url":"https://api.github.com/users/tkiethanom","html_url":"https://github.com/tkiethanom","followers_url":"https://api.github.com/users/tkiethanom/followers","following_url":"https://api.github.com/users/tkiethanom/following{/other_user}","gists_url":"https://api.github.com/users/tkiethanom/gists{/gist_id}","starred_url":"https://api.github.com/users/tkiethanom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkiethanom/subscriptions","organizations_url":"https://api.github.com/users/tkiethanom/orgs","repos_url":"https://api.github.com/users/tkiethanom/repos","events_url":"https://api.github.com/users/tkiethanom/events{/privacy}","received_events_url":"https://api.github.com/users/tkiethanom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-10T20:10:43Z","updated_at":"2015-09-10T20:42:03Z","closed_at":null,"body":"I have a simple route `/accounts/:acccountId`. When the page loads I use `componentDidMount()` to dispatch the request to get data from the API using the `accountId` param. \r\n\r\nThis works fine except when I link from `/accounts/1` to `/accounts/2`. The `componentDidMount()` already ran once so it will never fetch new data from the API. \r\n\r\nI've tried using some of the other life cycle methods `componentWillReceiveProps()` but since the dispatch updates the `props` I get stuck in a forever loop.  \r\n\r\nI can also do some checking within `componentWillReceiveProps()` but I was wondering if there is a better way to do this since this kind of thing would be used for any Model that has and ID.\r\n\r\n```javascript\r\ncomponentDidMount() {\r\n\tdispatch(fetchAccountView(this.props.params.accountId)); \r\n}\r\n\r\n//This will loop forever\r\ncomponentWillReceiveProps() {\r\n\tdispatch(fetchAccountView(this.props.params.accountId)); \r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/rackt/redux/issues/comments/139373150","html_url":"https://github.com/rackt/redux/issues/702#issuecomment-139373150","issue_url":"https://api.github.com/repos/rackt/redux/issues/702","id":139373150,"user":{"login":"tkiethanom","id":1057146,"avatar_url":"https://avatars.githubusercontent.com/u/1057146?v=3","gravatar_id":"","url":"https://api.github.com/users/tkiethanom","html_url":"https://github.com/tkiethanom","followers_url":"https://api.github.com/users/tkiethanom/followers","following_url":"https://api.github.com/users/tkiethanom/following{/other_user}","gists_url":"https://api.github.com/users/tkiethanom/gists{/gist_id}","starred_url":"https://api.github.com/users/tkiethanom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkiethanom/subscriptions","organizations_url":"https://api.github.com/users/tkiethanom/orgs","repos_url":"https://api.github.com/users/tkiethanom/repos","events_url":"https://api.github.com/users/tkiethanom/events{/privacy}","received_events_url":"https://api.github.com/users/tkiethanom/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T20:42:03Z","updated_at":"2015-09-10T20:42:03Z","body":"Okay I understand that I can do some checks in `componentWillReceiveProps()`. I'm looking for a way to do this without added repetitive code to each Page. \r\n\r\nI'm not sure how the `statics` translates to redux though. How or where would you put that code?"}}