{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/react-redux/issues/196","labels_url":"https://api.github.com/repos/rackt/react-redux/issues/196/labels{/name}","comments_url":"https://api.github.com/repos/rackt/react-redux/issues/196/comments","events_url":"https://api.github.com/repos/rackt/react-redux/issues/196/events","html_url":"https://github.com/rackt/react-redux/pull/196","id":118071468,"number":196,"title":"Prevent mapState from running twice when component is bound","user":{"login":"schmeedy","id":645661,"avatar_url":"https://avatars.githubusercontent.com/u/645661?v=3","gravatar_id":"","url":"https://api.github.com/users/schmeedy","html_url":"https://github.com/schmeedy","followers_url":"https://api.github.com/users/schmeedy/followers","following_url":"https://api.github.com/users/schmeedy/following{/other_user}","gists_url":"https://api.github.com/users/schmeedy/gists{/gist_id}","starred_url":"https://api.github.com/users/schmeedy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schmeedy/subscriptions","organizations_url":"https://api.github.com/users/schmeedy/orgs","repos_url":"https://api.github.com/users/schmeedy/repos","events_url":"https://api.github.com/users/schmeedy/events{/privacy}","received_events_url":"https://api.github.com/users/schmeedy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-20T16:04:48Z","updated_at":"2015-11-24T20:34:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rackt/react-redux/pulls/196","html_url":"https://github.com/rackt/react-redux/pull/196","diff_url":"https://github.com/rackt/react-redux/pull/196.diff","patch_url":"https://github.com/rackt/react-redux/pull/196.patch"},"body":"First, there's high probability this pull request is actually wrong and there's some fundamental thing in React / Redux that I violate by the proposed change given there are multiple unit tests which codify current approach. I still think there's some problem with it, though, so I appreciate if you look into this!\r\n\r\nI'm trying to prevent the `mapState` function from being called twice on each initial render of a \"connected component\" - first in the constructor and then right after that in `shouldComponentUpdate` where `stateProps` are recomputed because of difference in store state (as initially stored store state is always null). This second call can be avoided by simply initializing `this.state.storeState` with current store state during construction. \r\n\r\nIs this a viable solution? If not, is there some other way of preventing `mapState` to be called twice even though the state itself hasn't changed in between those two calls?"},"comment":{"url":"https://api.github.com/repos/rackt/react-redux/issues/comments/159397293","html_url":"https://github.com/rackt/react-redux/pull/196#issuecomment-159397293","issue_url":"https://api.github.com/repos/rackt/react-redux/issues/196","id":159397293,"user":{"login":"gaearon","id":810438,"avatar_url":"https://avatars.githubusercontent.com/u/810438?v=3","gravatar_id":"","url":"https://api.github.com/users/gaearon","html_url":"https://github.com/gaearon","followers_url":"https://api.github.com/users/gaearon/followers","following_url":"https://api.github.com/users/gaearon/following{/other_user}","gists_url":"https://api.github.com/users/gaearon/gists{/gist_id}","starred_url":"https://api.github.com/users/gaearon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaearon/subscriptions","organizations_url":"https://api.github.com/users/gaearon/orgs","repos_url":"https://api.github.com/users/gaearon/repos","events_url":"https://api.github.com/users/gaearon/events{/privacy}","received_events_url":"https://api.github.com/users/gaearon/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T20:34:00Z","updated_at":"2015-11-24T20:34:00Z","body":"This looks good to me.\r\n@epeli What do you think about this change? Any reason `storeState` was initialized to `null` in b6272698d2fc9ff7f67014b3e527579f738cd81d?"}}