{"action":"created","issue":{"url":"https://api.github.com/repos/markdalgleish/redial/issues/16","repository_url":"https://api.github.com/repos/markdalgleish/redial","labels_url":"https://api.github.com/repos/markdalgleish/redial/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/markdalgleish/redial/issues/16/comments","events_url":"https://api.github.com/repos/markdalgleish/redial/issues/16/events","html_url":"https://github.com/markdalgleish/redial/issues/16","id":133625430,"number":16,"title":"Nested routes - prevent fetching data on parent routes when navigate to child route","user":{"login":"joehua87","id":11925924,"avatar_url":"https://avatars.githubusercontent.com/u/11925924?v=3","gravatar_id":"","url":"https://api.github.com/users/joehua87","html_url":"https://github.com/joehua87","followers_url":"https://api.github.com/users/joehua87/followers","following_url":"https://api.github.com/users/joehua87/following{/other_user}","gists_url":"https://api.github.com/users/joehua87/gists{/gist_id}","starred_url":"https://api.github.com/users/joehua87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joehua87/subscriptions","organizations_url":"https://api.github.com/users/joehua87/orgs","repos_url":"https://api.github.com/users/joehua87/repos","events_url":"https://api.github.com/users/joehua87/events{/privacy}","received_events_url":"https://api.github.com/users/joehua87/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-15T05:22:06Z","updated_at":"2016-02-23T08:00:03Z","closed_at":null,"body":"Hello, Thank you for your awesome lib, it helps a lot :smiley: \r\n\r\nI face some problem when working with nested route.\r\n\r\nGiven we have route like:\r\n```js\r\n  <Route path=\"/\" component={App}>\r\n    <Route path=\"user\" component={User}>\r\n      <Route path=\":username\" component={UserDetail}/>\r\n    </Route>\r\n  </Route>\r\n```\r\n* Render /user:\r\n  * Server: ok\r\n  * Client: ok\r\n* Render /user/:username\r\n  * Server: ok\r\n  * Client: problem - the users list will reload everytime we navigate to /user/:username\r\n\r\nQuestion: **Does we have any way to prevent reloading users everytime we navigate to /user/:username?**\r\nCan we provide current state in fetch function like this?\r\n```js\r\nconst hooks = {\r\n  fetch: ({ dispatch, query: { keyword, repos, followers }, entities }) => {\r\n    if (!entities) { // Only reload entities when entities doesn't exists to prevent duplicated load\r\n    return dispatch(getUsers({ keyword, repos, followers }))\r\n    }\r\n  }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/markdalgleish/redial/issues/comments/187592420","html_url":"https://github.com/markdalgleish/redial/issues/16#issuecomment-187592420","issue_url":"https://api.github.com/repos/markdalgleish/redial/issues/16","id":187592420,"user":{"login":"maslianok","id":3485490,"avatar_url":"https://avatars.githubusercontent.com/u/3485490?v=3","gravatar_id":"","url":"https://api.github.com/users/maslianok","html_url":"https://github.com/maslianok","followers_url":"https://api.github.com/users/maslianok/followers","following_url":"https://api.github.com/users/maslianok/following{/other_user}","gists_url":"https://api.github.com/users/maslianok/gists{/gist_id}","starred_url":"https://api.github.com/users/maslianok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maslianok/subscriptions","organizations_url":"https://api.github.com/users/maslianok/orgs","repos_url":"https://api.github.com/users/maslianok/repos","events_url":"https://api.github.com/users/maslianok/events{/privacy}","received_events_url":"https://api.github.com/users/maslianok/received_events","type":"User","site_admin":false},"created_at":"2016-02-23T08:00:03Z","updated_at":"2016-02-23T08:00:03Z","body":"@joehua87, you can pass store through locals and then check global state, e.g.\r\n```javascript\r\n// Set up Redux (note: this API requires redux@>=3.1.0):\r\n  const store = createStore(reducer, initialState, applyMiddleware(thunk));\r\n\r\n  // Listen for route changes on the browser history instance:\r\n  browserHistory.listen(location => {\r\n    // Match routes based on location object:\r\n    match({ routes, location }, (error, redirectLocation, renderProps) => {\r\n      // Get array of route handler components:\r\n      const { components } = renderProps;\r\n\r\n      // Define locals to be provided to all lifecycle hooks:\r\n      const locals = {\r\n        path: renderProps.location.pathname,\r\n        query: renderProps.location.query,\r\n        params: renderProps.params,\r\n\r\n        // ----------CHANGED-------- Pass store here\r\n        store\r\n      };\r\n      ...\r\n    });\r\n  });\r\n```\r\nAnd then use it like this\r\n```javascript\r\nconst hooks = {\r\n  fetch: ({ store: {dispatch, getState}, params: { id } }) => {\r\n    if (!getState().entities)\r\n      return dispatch(getSomething(id));\r\n    }\r\n  }\r\n};\r\n```"}}