{"action":"created","issue":{"url":"https://api.github.com/repos/gaearon/redux/issues/227","labels_url":"https://api.github.com/repos/gaearon/redux/issues/227/labels{/name}","comments_url":"https://api.github.com/repos/gaearon/redux/issues/227/comments","events_url":"https://api.github.com/repos/gaearon/redux/issues/227/events","html_url":"https://github.com/gaearon/redux/issues/227","id":93519931,"number":227,"title":"firing actions in response to route transitions in react-router","user":{"login":"deowk","id":5707616,"avatar_url":"https://avatars.githubusercontent.com/u/5707616?v=3","gravatar_id":"","url":"https://api.github.com/users/deowk","html_url":"https://github.com/deowk","followers_url":"https://api.github.com/users/deowk/followers","following_url":"https://api.github.com/users/deowk/following{/other_user}","gists_url":"https://api.github.com/users/deowk/gists{/gist_id}","starred_url":"https://api.github.com/users/deowk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deowk/subscriptions","organizations_url":"https://api.github.com/users/deowk/orgs","repos_url":"https://api.github.com/users/deowk/repos","events_url":"https://api.github.com/users/deowk/events{/privacy}","received_events_url":"https://api.github.com/users/deowk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gaearon/redux/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-07T12:30:27Z","updated_at":"2015-07-11T13:46:50Z","closed_at":null,"body":"Hi Guys, \r\n\r\nI am using react-router and redux in my latest app and I'm facing a couple of issues relating to state changes required based on the current url params and queries.\r\n\r\nBasically I have a component that needs to update it's state every time the url changes. State is being passed in through props by redux with the decorator like so \r\n\r\n```\r\n @connect(state => ({\r\n   campaigngroups: state.jobresults.campaigngroups,\r\n   error: state.jobresults.error,\r\n   loading: state.jobresults.loading\r\n }))\r\n```\r\n\r\nAt the moment I am using the `componentWillReceiveProps` lifecycle method to respond to the url changes coming from react-router since react-router will pass new props to the handler when the url changes in `this.props.params` and `this.props.query` - the main issue with this approach is that I am firing an action in this method to update the state - which then goes and passes new props the component which will trigger the same lifecycle method again - so basically creating an endless loop, currently I am setting a state variable to stop this from happening.\r\n\r\n```\r\n  componentWillReceiveProps(nextProps) {\r\n    if (this.state.shouldupdate) {\r\n      let { slug } = nextProps.params;\r\n      let { citizenships, discipline, workright, location } = nextProps.query;\r\n      const params = { slug, discipline, workright, location };\r\n      let filters = this._getFilters(params);\r\n      // set the state accroding to the filters in the url\r\n      this._setState(params);\r\n      // trigger the action to refill the stores\r\n      this.actions.loadCampaignGroups(filters);\r\n    }\r\n  }\r\n```\r\n\r\nIs there a standard approach to trigger actions base on route transitions OR can I have the state of the store directly connected to the state of the component instead of passing it in through props? I have tried to use `willTransitionTo` static method but I don't have access to the this.props.dispatch there."},"comment":{"url":"https://api.github.com/repos/gaearon/redux/issues/comments/120620752","html_url":"https://github.com/gaearon/redux/issues/227#issuecomment-120620752","issue_url":"https://api.github.com/repos/gaearon/redux/issues/227","id":120620752,"user":{"login":"gyzerok","id":1706020,"avatar_url":"https://avatars.githubusercontent.com/u/1706020?v=3","gravatar_id":"","url":"https://api.github.com/users/gyzerok","html_url":"https://github.com/gyzerok","followers_url":"https://api.github.com/users/gyzerok/followers","following_url":"https://api.github.com/users/gyzerok/following{/other_user}","gists_url":"https://api.github.com/users/gyzerok/gists{/gist_id}","starred_url":"https://api.github.com/users/gyzerok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyzerok/subscriptions","organizations_url":"https://api.github.com/users/gyzerok/orgs","repos_url":"https://api.github.com/users/gyzerok/repos","events_url":"https://api.github.com/users/gyzerok/events{/privacy}","received_events_url":"https://api.github.com/users/gyzerok/received_events","type":"User","site_admin":false},"created_at":"2015-07-11T13:46:50Z","updated_at":"2015-07-11T13:46:50Z","body":"@pburtchaell can you share your routeLocationDidUpdate?"}}