{"action":"created","issue":{"url":"https://api.github.com/repos/react-community/react-navigation/issues/1560","repository_url":"https://api.github.com/repos/react-community/react-navigation","labels_url":"https://api.github.com/repos/react-community/react-navigation/issues/1560/labels{/name}","comments_url":"https://api.github.com/repos/react-community/react-navigation/issues/1560/comments","events_url":"https://api.github.com/repos/react-community/react-navigation/issues/1560/events","html_url":"https://github.com/react-community/react-navigation/issues/1560","id":229386057,"number":1560,"title":"Update tabNavigator screen only when it's active (using redux)","user":{"login":"pjamrozowicz","id":10074468,"avatar_url":"https://avatars0.githubusercontent.com/u/10074468?v=3","gravatar_id":"","url":"https://api.github.com/users/pjamrozowicz","html_url":"https://github.com/pjamrozowicz","followers_url":"https://api.github.com/users/pjamrozowicz/followers","following_url":"https://api.github.com/users/pjamrozowicz/following{/other_user}","gists_url":"https://api.github.com/users/pjamrozowicz/gists{/gist_id}","starred_url":"https://api.github.com/users/pjamrozowicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjamrozowicz/subscriptions","organizations_url":"https://api.github.com/users/pjamrozowicz/orgs","repos_url":"https://api.github.com/users/pjamrozowicz/repos","events_url":"https://api.github.com/users/pjamrozowicz/events{/privacy}","received_events_url":"https://api.github.com/users/pjamrozowicz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-17T15:08:36Z","updated_at":"2017-05-17T19:47:47Z","closed_at":"2017-05-17T19:47:47Z","body":"\r\nLet say I have some values in a redux store. I have 2 screens and both are using these values. When I am on a first screen and values inside the store change, I want to update only this active screen. The second one should re-render only when I open it. I am using redux, I keep TabNavigator state inside it, and I tried implementing _shouldComponentUpdate_ on a second screen to update only when:\r\n`this.props.nav.routes[this.props.nav.index].routeName === 'secondScreen'` is true.\r\n\r\nThe problem is though, _shouldComponentUpdate_ fires before the TabNavigator updates index value inside the store. So when I am on a first screen and values inside store change - it is okay, second screen isn't re-rendered but when I go to the second screen, it still doesn't get re-rendered.\r\n\r\nAny advice on how to implement it with TabNavigator?\r\n"},"comment":{"url":"https://api.github.com/repos/react-community/react-navigation/issues/comments/302212061","html_url":"https://github.com/react-community/react-navigation/issues/1560#issuecomment-302212061","issue_url":"https://api.github.com/repos/react-community/react-navigation/issues/1560","id":302212061,"user":{"login":"pjamrozowicz","id":10074468,"avatar_url":"https://avatars0.githubusercontent.com/u/10074468?v=3","gravatar_id":"","url":"https://api.github.com/users/pjamrozowicz","html_url":"https://github.com/pjamrozowicz","followers_url":"https://api.github.com/users/pjamrozowicz/followers","following_url":"https://api.github.com/users/pjamrozowicz/following{/other_user}","gists_url":"https://api.github.com/users/pjamrozowicz/gists{/gist_id}","starred_url":"https://api.github.com/users/pjamrozowicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjamrozowicz/subscriptions","organizations_url":"https://api.github.com/users/pjamrozowicz/orgs","repos_url":"https://api.github.com/users/pjamrozowicz/repos","events_url":"https://api.github.com/users/pjamrozowicz/events{/privacy}","received_events_url":"https://api.github.com/users/pjamrozowicz/received_events","type":"User","site_admin":false},"created_at":"2017-05-17T19:47:47Z","updated_at":"2017-05-17T19:47:47Z","body":"Okay, that was my bad, I was testing old value of props inside _shouldComponentUpdate_, not the new ones.\r\n\r\nSo this function do the trick:\r\n`  shouldComponentUpdate(nextProps, nextState){\r\n    if(nextProps.nav.routes[nextProps.nav.index].routeName === 'componentName'){\r\n      return true;\r\n    } else {\r\n      return false;\r\n    }\r\n  }`\r\n\r\nAnd the component is subscribed to navigation state changes using redux.\r\n\r\n`const mapStateToProps = (state) => {\r\n  return {\r\n    nav: state.nav,\r\n  };\r\n};`\r\n"}}
{"actor":{"display_login":"pjamrozowicz"}}