{"action":"created","comment":{"url":"https://api.github.com/repos/reactjs/redux/pulls/comments/77925540","id":77925540,"diff_hunk":"@@ -0,0 +1,88 @@\n+# Prerequisite Reducer Concepts\n+\n+\n+As described in [Reducers](../../basics/Reducers.md), a Redux reducer function:\n+\n+- Should have a signature of `(previousState, action) => newState`, similar to the type of function you would pass to [`Array.prototype.reduce(reducer, ?initialValue)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)\n+- Should be \"pure\", which means it does not mutate its arguments, perform side effects like API calls or modifying values outside of the function, or call non-pure functions like `Date.now()` or `Math.random()`.  This also means that updates should be done in an ***\"immutable\"*** fashion, which means **always returning new objects with the updated data**, rather than directly modifying the original state tree in-place.\n+\n+>##### Note on immutability, side effects, and mutation\n+> Mutation is discouraged because it generally breaks time-travel debugging, and React Redux's `connect` function.  For time traveling, the Redux DevTools expect that replaying recorded actions would output a state value, but not change anything else.  For React Redux, `connect` checks to see if the values returned from a `mapStateToProps` function have changed in order to see if a component needs to update.  Direct mutation can cause both of these scenarios to not work correctly.  Other side effects like generating unique IDs or timestamps in a reducer also make the code unpredictable and harder to debug.  ","path":"docs/recipes/reducers/00-PrerequisiteConcepts.md","position":10,"original_position":10,"commit_id":"3bc8af18d45c878d45b0a90baf6df7b52260c412","original_commit_id":"3bc8af18d45c878d45b0a90baf6df7b52260c412","user":{"login":"ellbee","id":6018379,"avatar_url":"https://avatars.githubusercontent.com/u/6018379?v=3","gravatar_id":"","url":"https://api.github.com/users/ellbee","html_url":"https://github.com/ellbee","followers_url":"https://api.github.com/users/ellbee/followers","following_url":"https://api.github.com/users/ellbee/following{/other_user}","gists_url":"https://api.github.com/users/ellbee/gists{/gist_id}","starred_url":"https://api.github.com/users/ellbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellbee/subscriptions","organizations_url":"https://api.github.com/users/ellbee/orgs","repos_url":"https://api.github.com/users/ellbee/repos","events_url":"https://api.github.com/users/ellbee/events{/privacy}","received_events_url":"https://api.github.com/users/ellbee/received_events","type":"User","site_admin":false},"body":"Yeah, good point. In my hypothetical deep equality check I was assuming there would be a copy of the props to compare against. Another go:\r\n\r\n> For React Redux, `connect` checks to see if the props returned from a `mapStateToProps` function have changed in order to determine if a component needs to update. `connect` **does not** deeply compare each value from the new props with a copy of that value from the old props, it instead takes some shortcuts that rely on the state being **immutable**,  so changes made to objects and arrays by direct mutation will not be detected.","created_at":"2016-09-07T23:50:44Z","updated_at":"2016-09-07T23:50:44Z","html_url":"https://github.com/reactjs/redux/pull/1930#discussion_r77925540","pull_request_url":"https://api.github.com/repos/reactjs/redux/pulls/1930","_links":{"self":{"href":"https://api.github.com/repos/reactjs/redux/pulls/comments/77925540"},"html":{"href":"https://github.com/reactjs/redux/pull/1930#discussion_r77925540"},"pull_request":{"href":"https://api.github.com/repos/reactjs/redux/pulls/1930"}}},"pull_request":{"url":"https://api.github.com/repos/reactjs/redux/pulls/1930","id":83937264,"html_url":"https://github.com/reactjs/redux/pull/1930","diff_url":"https://github.com/reactjs/redux/pull/1930.diff","patch_url":"https://github.com/reactjs/redux/pull/1930.patch","issue_url":"https://api.github.com/repos/reactjs/redux/issues/1930","number":1930,"state":"open","locked":false,"title":"Structuring reducers page","user":{"login":"markerikson","id":1128784,"avatar_url":"https://avatars.githubusercontent.com/u/1128784?v=3","gravatar_id":"","url":"https://api.github.com/users/markerikson","html_url":"https://github.com/markerikson","followers_url":"https://api.github.com/users/markerikson/followers","following_url":"https://api.github.com/users/markerikson/following{/other_user}","gists_url":"https://api.github.com/users/markerikson/gists{/gist_id}","starred_url":"https://api.github.com/users/markerikson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerikson/subscriptions","organizations_url":"https://api.github.com/users/markerikson/orgs","repos_url":"https://api.github.com/users/markerikson/repos","events_url":"https://api.github.com/users/markerikson/events{/privacy}","received_events_url":"https://api.github.com/users/markerikson/received_events","type":"User","site_admin":false},"body":"Initial content review for #1784 .  Please give feedback on content, formatting, structure, and ordering of topics.  Current content is a first draft, and I expect I'll need to make numerous changes before it's ready to merge.","created_at":"2016-09-04T23:23:24Z","updated_at":"2016-09-07T23:50:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d5914623ad10d3709bf3d54a28d199cd814c7ba","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/reactjs/redux/pulls/1930/commits","review_comments_url":"https://api.github.com/repos/reactjs/redux/pulls/1930/comments","review_comment_url":"https://api.github.com/repos/reactjs/redux/pulls/comments{/number}","comments_url":"https://api.github.com/repos/reactjs/redux/issues/1930/comments","statuses_url":"https://api.github.com/repos/reactjs/redux/statuses/3bc8af18d45c878d45b0a90baf6df7b52260c412","head":{"label":"markerikson:structuring-reducers-page","ref":"structuring-reducers-page","sha":"3bc8af18d45c878d45b0a90baf6df7b52260c412","user":{"login":"markerikson","id":1128784,"avatar_url":"https://avatars.githubusercontent.com/u/1128784?v=3","gravatar_id":"","url":"https://api.github.com/users/markerikson","html_url":"https://github.com/markerikson","followers_url":"https://api.github.com/users/markerikson/followers","following_url":"https://api.github.com/users/markerikson/following{/other_user}","gists_url":"https://api.github.com/users/markerikson/gists{/gist_id}","starred_url":"https://api.github.com/users/markerikson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerikson/subscriptions","organizations_url":"https://api.github.com/users/markerikson/orgs","repos_url":"https://api.github.com/users/markerikson/repos","events_url":"https://api.github.com/users/markerikson/events{/privacy}","received_events_url":"https://api.github.com/users/markerikson/received_events","type":"User","site_admin":false},"repo":{"id":51805024,"name":"redux","full_name":"markerikson/redux","owner":{"login":"markerikson","id":1128784,"avatar_url":"https://avatars.githubusercontent.com/u/1128784?v=3","gravatar_id":"","url":"https://api.github.com/users/markerikson","html_url":"https://github.com/markerikson","followers_url":"https://api.github.com/users/markerikson/followers","following_url":"https://api.github.com/users/markerikson/following{/other_user}","gists_url":"https://api.github.com/users/markerikson/gists{/gist_id}","starred_url":"https://api.github.com/users/markerikson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markerikson/subscriptions","organizations_url":"https://api.github.com/users/markerikson/orgs","repos_url":"https://api.github.com/users/markerikson/repos","events_url":"https://api.github.com/users/markerikson/events{/privacy}","received_events_url":"https://api.github.com/users/markerikson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markerikson/redux","description":"Predictable state container for JavaScript apps","fork":true,"url":"https://api.github.com/repos/markerikson/redux","forks_url":"https://api.github.com/repos/markerikson/redux/forks","keys_url":"https://api.github.com/repos/markerikson/redux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markerikson/redux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markerikson/redux/teams","hooks_url":"https://api.github.com/repos/markerikson/redux/hooks","issue_events_url":"https://api.github.com/repos/markerikson/redux/issues/events{/number}","events_url":"https://api.github.com/repos/markerikson/redux/events","assignees_url":"https://api.github.com/repos/markerikson/redux/assignees{/user}","branches_url":"https://api.github.com/repos/markerikson/redux/branches{/branch}","tags_url":"https://api.github.com/repos/markerikson/redux/tags","blobs_url":"https://api.github.com/repos/markerikson/redux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markerikson/redux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markerikson/redux/git/refs{/sha}","trees_url":"https://api.github.com/repos/markerikson/redux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markerikson/redux/statuses/{sha}","languages_url":"https://api.github.com/repos/markerikson/redux/languages","stargazers_url":"https://api.github.com/repos/markerikson/redux/stargazers","contributors_url":"https://api.github.com/repos/markerikson/redux/contributors","subscribers_url":"https://api.github.com/repos/markerikson/redux/subscribers","subscription_url":"https://api.github.com/repos/markerikson/redux/subscription","commits_url":"https://api.github.com/repos/markerikson/redux/commits{/sha}","git_commits_url":"https://api.github.com/repos/markerikson/redux/git/commits{/sha}","comments_url":"https://api.github.com/repos/markerikson/redux/comments{/number}","issue_comment_url":"https://api.github.com/repos/markerikson/redux/issues/comments{/number}","contents_url":"https://api.github.com/repos/markerikson/redux/contents/{+path}","compare_url":"https://api.github.com/repos/markerikson/redux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markerikson/redux/merges","archive_url":"https://api.github.com/repos/markerikson/redux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markerikson/redux/downloads","issues_url":"https://api.github.com/repos/markerikson/redux/issues{/number}","pulls_url":"https://api.github.com/repos/markerikson/redux/pulls{/number}","milestones_url":"https://api.github.com/repos/markerikson/redux/milestones{/number}","notifications_url":"https://api.github.com/repos/markerikson/redux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markerikson/redux/labels{/name}","releases_url":"https://api.github.com/repos/markerikson/redux/releases{/id}","deployments_url":"https://api.github.com/repos/markerikson/redux/deployments","created_at":"2016-02-16T03:26:59Z","updated_at":"2016-09-06T15:17:39Z","pushed_at":"2016-09-04T22:30:01Z","git_url":"git://github.com/markerikson/redux.git","ssh_url":"git@github.com:markerikson/redux.git","clone_url":"https://github.com/markerikson/redux.git","svn_url":"https://github.com/markerikson/redux","homepage":"http://redux.js.org","size":3541,"stargazers_count":34,"watchers_count":34,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":0,"forks":12,"open_issues":0,"watchers":34,"default_branch":"master"}},"base":{"label":"reactjs:master","ref":"master","sha":"3e114f8c0fd4461e2f642c2737d2fa8297484728","user":{"login":"reactjs","id":6412038,"avatar_url":"https://avatars.githubusercontent.com/u/6412038?v=3","gravatar_id":"","url":"https://api.github.com/users/reactjs","html_url":"https://github.com/reactjs","followers_url":"https://api.github.com/users/reactjs/followers","following_url":"https://api.github.com/users/reactjs/following{/other_user}","gists_url":"https://api.github.com/users/reactjs/gists{/gist_id}","starred_url":"https://api.github.com/users/reactjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactjs/subscriptions","organizations_url":"https://api.github.com/users/reactjs/orgs","repos_url":"https://api.github.com/users/reactjs/repos","events_url":"https://api.github.com/users/reactjs/events{/privacy}","received_events_url":"https://api.github.com/users/reactjs/received_events","type":"Organization","site_admin":false},"repo":{"id":36535156,"name":"redux","full_name":"reactjs/redux","owner":{"login":"reactjs","id":6412038,"avatar_url":"https://avatars.githubusercontent.com/u/6412038?v=3","gravatar_id":"","url":"https://api.github.com/users/reactjs","html_url":"https://github.com/reactjs","followers_url":"https://api.github.com/users/reactjs/followers","following_url":"https://api.github.com/users/reactjs/following{/other_user}","gists_url":"https://api.github.com/users/reactjs/gists{/gist_id}","starred_url":"https://api.github.com/users/reactjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reactjs/subscriptions","organizations_url":"https://api.github.com/users/reactjs/orgs","repos_url":"https://api.github.com/users/reactjs/repos","events_url":"https://api.github.com/users/reactjs/events{/privacy}","received_events_url":"https://api.github.com/users/reactjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reactjs/redux","description":"Predictable state container for JavaScript apps","fork":false,"url":"https://api.github.com/repos/reactjs/redux","forks_url":"https://api.github.com/repos/reactjs/redux/forks","keys_url":"https://api.github.com/repos/reactjs/redux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reactjs/redux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reactjs/redux/teams","hooks_url":"https://api.github.com/repos/reactjs/redux/hooks","issue_events_url":"https://api.github.com/repos/reactjs/redux/issues/events{/number}","events_url":"https://api.github.com/repos/reactjs/redux/events","assignees_url":"https://api.github.com/repos/reactjs/redux/assignees{/user}","branches_url":"https://api.github.com/repos/reactjs/redux/branches{/branch}","tags_url":"https://api.github.com/repos/reactjs/redux/tags","blobs_url":"https://api.github.com/repos/reactjs/redux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reactjs/redux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reactjs/redux/git/refs{/sha}","trees_url":"https://api.github.com/repos/reactjs/redux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reactjs/redux/statuses/{sha}","languages_url":"https://api.github.com/repos/reactjs/redux/languages","stargazers_url":"https://api.github.com/repos/reactjs/redux/stargazers","contributors_url":"https://api.github.com/repos/reactjs/redux/contributors","subscribers_url":"https://api.github.com/repos/reactjs/redux/subscribers","subscription_url":"https://api.github.com/repos/reactjs/redux/subscription","commits_url":"https://api.github.com/repos/reactjs/redux/commits{/sha}","git_commits_url":"https://api.github.com/repos/reactjs/redux/git/commits{/sha}","comments_url":"https://api.github.com/repos/reactjs/redux/comments{/number}","issue_comment_url":"https://api.github.com/repos/reactjs/redux/issues/comments{/number}","contents_url":"https://api.github.com/repos/reactjs/redux/contents/{+path}","compare_url":"https://api.github.com/repos/reactjs/redux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reactjs/redux/merges","archive_url":"https://api.github.com/repos/reactjs/redux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reactjs/redux/downloads","issues_url":"https://api.github.com/repos/reactjs/redux/issues{/number}","pulls_url":"https://api.github.com/repos/reactjs/redux/pulls{/number}","milestones_url":"https://api.github.com/repos/reactjs/redux/milestones{/number}","notifications_url":"https://api.github.com/repos/reactjs/redux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reactjs/redux/labels{/name}","releases_url":"https://api.github.com/repos/reactjs/redux/releases{/id}","deployments_url":"https://api.github.com/repos/reactjs/redux/deployments","created_at":"2015-05-29T23:53:15Z","updated_at":"2016-09-07T23:47:21Z","pushed_at":"2016-09-07T19:13:51Z","git_url":"git://github.com/reactjs/redux.git","ssh_url":"git@github.com:reactjs/redux.git","clone_url":"https://github.com/reactjs/redux.git","svn_url":"https://github.com/reactjs/redux","homepage":"http://redux.js.org","size":14095,"stargazers_count":22787,"watchers_count":22787,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":3544,"mirror_url":null,"open_issues_count":51,"forks":3544,"open_issues":51,"watchers":22787,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/reactjs/redux/pulls/1930"},"html":{"href":"https://github.com/reactjs/redux/pull/1930"},"issue":{"href":"https://api.github.com/repos/reactjs/redux/issues/1930"},"comments":{"href":"https://api.github.com/repos/reactjs/redux/issues/1930/comments"},"review_comments":{"href":"https://api.github.com/repos/reactjs/redux/pulls/1930/comments"},"review_comment":{"href":"https://api.github.com/repos/reactjs/redux/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/reactjs/redux/pulls/1930/commits"},"statuses":{"href":"https://api.github.com/repos/reactjs/redux/statuses/3bc8af18d45c878d45b0a90baf6df7b52260c412"}}}}
{"actor":{"display_login":"ellbee"}}