GitHub PullRequestReviewCommentEvent at 2014-12-15 17:52:39
Repository: react-localstorage
Actor: STRML
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/STRML/react-localstorage/pulls/comments/21842508","id":21842508,"diff_hunk":"@@ -22,22 +22,36 @@ var Mixin = module.exports = {\n \n   componentWillMount: function() {\n     loadStateFromLocalStorage(this);\n+  },\n+\n+  componentDidMount: function () {\n+    // we have to save it to make the saved state\n+    // correspond to the updated component state structure\n+    ls.setItem(getLocalStorageKey(this), JSON.stringify(this.state));\n   }\n };\n \n function loadStateFromLocalStorage(component) {\n   if (!ls) return;\n   var key = getLocalStorageKey(component);\n-  var storedState = ls.getItem(key);\n+  // `storedState` is string type, we need to parse it first.\n+  // otherwise, the if statement will always be true.\n+  var storedState = JSON.parse(ls.getItem(key));","path":"react-localstorage.js","position":32,"original_position":32,"commit_id":"621e9618ec1e7cb28d2834ad4b7d485a4c6fa108","original_commit_id":"621e9618ec1e7cb28d2834ad4b7d485a4c6fa108","user":{"login":"STRML","id":1197375,"avatar_url":"https://avatars.githubusercontent.com/u/1197375?v=3","gravatar_id":"","url":"https://api.github.com/users/STRML","html_url":"https://github.com/STRML","followers_url":"https://api.github.com/users/STRML/followers","following_url":"https://api.github.com/users/STRML/following{/other_user}","gists_url":"https://api.github.com/users/STRML/gists{/gist_id}","starred_url":"https://api.github.com/users/STRML/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STRML/subscriptions","organizations_url":"https://api.github.com/users/STRML/orgs","repos_url":"https://api.github.com/users/STRML/repos","events_url":"https://api.github.com/users/STRML/events{/privacy}","received_events_url":"https://api.github.com/users/STRML/received_events","type":"User","site_admin":false},"body":"Why did you move the `JSON.parse()` here? That's what the try/catch below this is for :)","created_at":"2014-12-15T17:52:39Z","updated_at":"2014-12-15T17:52:39Z","html_url":"https://github.com/STRML/react-localstorage/pull/1#discussion_r21842508","pull_request_url":"https://api.github.com/repos/STRML/react-localstorage/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/STRML/react-localstorage/pulls/comments/21842508"},"html":{"href":"https://github.com/STRML/react-localstorage/pull/1#discussion_r21842508"},"pull_request":{"href":"https://api.github.com/repos/STRML/react-localstorage/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/STRML/react-localstorage/pulls/1","id":26087288,"html_url":"https://github.com/STRML/react-localstorage/pull/1","diff_url":"https://github.com/STRML/react-localstorage/pull/1.diff","patch_url":"https://github.com/STRML/react-localstorage/pull/1.patch","issue_url":"https://api.github.com/repos/STRML/react-localstorage/issues/1","number":1,"state":"open","locked":false,"title":"fix bugs and setup test environment","user":{"login":"ssnau","id":738660,"avatar_url":"https://avatars.githubusercontent.com/u/738660?v=3","gravatar_id":"","url":"https://api.github.com/users/ssnau","html_url":"https://github.com/ssnau","followers_url":"https://api.github.com/users/ssnau/followers","following_url":"https://api.github.com/users/ssnau/following{/other_user}","gists_url":"https://api.github.com/users/ssnau/gists{/gist_id}","starred_url":"https://api.github.com/users/ssnau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssnau/subscriptions","organizations_url":"https://api.github.com/users/ssnau/orgs","repos_url":"https://api.github.com/users/ssnau/repos","events_url":"https://api.github.com/users/ssnau/events{/privacy}","received_events_url":"https://api.github.com/users/ssnau/received_events","type":"User","site_admin":false},"body":"1. setup test environment using karma\r\n2. write 6 test cases to ensure correction\r\n3. fix `displayName` bug\r\n4. prevent throwing invariant error after we update the initial structure of this.state","created_at":"2014-12-15T17:45:36Z","updated_at":"2014-12-15T17:52:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"58557d8f9f8066dcab0a2c7a04d2058b7e0bc8cf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/STRML/react-localstorage/pulls/1/commits","review_comments_url":"https://api.github.com/repos/STRML/react-localstorage/pulls/1/comments","review_comment_url":"https://api.github.com/repos/STRML/react-localstorage/pulls/comments/{number}","comments_url":"https://api.github.com/repos/STRML/react-localstorage/issues/1/comments","statuses_url":"https://api.github.com/repos/STRML/react-localstorage/statuses/621e9618ec1e7cb28d2834ad4b7d485a4c6fa108","head":{"label":"ssnau:master","ref":"master","sha":"621e9618ec1e7cb28d2834ad4b7d485a4c6fa108","user":{"login":"ssnau","id":738660,"avatar_url":"https://avatars.githubusercontent.com/u/738660?v=3","gravatar_id":"","url":"https://api.github.com/users/ssnau","html_url":"https://github.com/ssnau","followers_url":"https://api.github.com/users/ssnau/followers","following_url":"https://api.github.com/users/ssnau/following{/other_user}","gists_url":"https://api.github.com/users/ssnau/gists{/gist_id}","starred_url":"https://api.github.com/users/ssnau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssnau/subscriptions","organizations_url":"https://api.github.com/users/ssnau/orgs","repos_url":"https://api.github.com/users/ssnau/repos","events_url":"https://api.github.com/users/ssnau/events{/privacy}","received_events_url":"https://api.github.com/users/ssnau/received_events","type":"User","site_admin":false},"repo":{"id":28041477,"name":"react-localstorage","full_name":"ssnau/react-localstorage","owner":{"login":"ssnau","id":738660,"avatar_url":"https://avatars.githubusercontent.com/u/738660?v=3","gravatar_id":"","url":"https://api.github.com/users/ssnau","html_url":"https://github.com/ssnau","followers_url":"https://api.github.com/users/ssnau/followers","following_url":"https://api.github.com/users/ssnau/following{/other_user}","gists_url":"https://api.github.com/users/ssnau/gists{/gist_id}","starred_url":"https://api.github.com/users/ssnau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssnau/subscriptions","organizations_url":"https://api.github.com/users/ssnau/orgs","repos_url":"https://api.github.com/users/ssnau/repos","events_url":"https://api.github.com/users/ssnau/events{/privacy}","received_events_url":"https://api.github.com/users/ssnau/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ssnau/react-localstorage","description":"Simple componentized localstorage implementation for Facebook's React.","fork":true,"url":"https://api.github.com/repos/ssnau/react-localstorage","forks_url":"https://api.github.com/repos/ssnau/react-localstorage/forks","keys_url":"https://api.github.com/repos/ssnau/react-localstorage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ssnau/react-localstorage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ssnau/react-localstorage/teams","hooks_url":"https://api.github.com/repos/ssnau/react-localstorage/hooks","issue_events_url":"https://api.github.com/repos/ssnau/react-localstorage/issues/events{/number}","events_url":"https://api.github.com/repos/ssnau/react-localstorage/events","assignees_url":"https://api.github.com/repos/ssnau/react-localstorage/assignees{/user}","branches_url":"https://api.github.com/repos/ssnau/react-localstorage/branches{/branch}","tags_url":"https://api.github.com/repos/ssnau/react-localstorage/tags","blobs_url":"https://api.github.com/repos/ssnau/react-localstorage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ssnau/react-localstorage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ssnau/react-localstorage/git/refs{/sha}","trees_url":"https://api.github.com/repos/ssnau/react-localstorage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ssnau/react-localstorage/statuses/{sha}","languages_url":"https://api.github.com/repos/ssnau/react-localstorage/languages","stargazers_url":"https://api.github.com/repos/ssnau/react-localstorage/stargazers","contributors_url":"https://api.github.com/repos/ssnau/react-localstorage/contributors","subscribers_url":"https://api.github.com/repos/ssnau/react-localstorage/subscribers","subscription_url":"https://api.github.com/repos/ssnau/react-localstorage/subscription","commits_url":"https://api.github.com/repos/ssnau/react-localstorage/commits{/sha}","git_commits_url":"https://api.github.com/repos/ssnau/react-localstorage/git/commits{/sha}","comments_url":"https://api.github.com/repos/ssnau/react-localstorage/comments{/number}","issue_comment_url":"https://api.github.com/repos/ssnau/react-localstorage/issues/comments/{number}","contents_url":"https://api.github.com/repos/ssnau/react-localstorage/contents/{+path}","compare_url":"https://api.github.com/repos/ssnau/react-localstorage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ssnau/react-localstorage/merges","archive_url":"https://api.github.com/repos/ssnau/react-localstorage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ssnau/react-localstorage/downloads","issues_url":"https://api.github.com/repos/ssnau/react-localstorage/issues{/number}","pulls_url":"https://api.github.com/repos/ssnau/react-localstorage/pulls{/number}","milestones_url":"https://api.github.com/repos/ssnau/react-localstorage/milestones{/number}","notifications_url":"https://api.github.com/repos/ssnau/react-localstorage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ssnau/react-localstorage/labels{/name}","releases_url":"https://api.github.com/repos/ssnau/react-localstorage/releases{/id}","created_at":"2014-12-15T15:00:53Z","updated_at":"2014-12-15T17:38:18Z","pushed_at":"2014-12-15T17:38:18Z","git_url":"git://github.com/ssnau/react-localstorage.git","ssh_url":"git@github.com:ssnau/react-localstorage.git","clone_url":"https://github.com/ssnau/react-localstorage.git","svn_url":"https://github.com/ssnau/react-localstorage","homepage":null,"size":100,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"STRML:master","ref":"master","sha":"e463a442b1362fd18c4bd5cfa650c854309874e7","user":{"login":"STRML","id":1197375,"avatar_url":"https://avatars.githubusercontent.com/u/1197375?v=3","gravatar_id":"","url":"https://api.github.com/users/STRML","html_url":"https://github.com/STRML","followers_url":"https://api.github.com/users/STRML/followers","following_url":"https://api.github.com/users/STRML/following{/other_user}","gists_url":"https://api.github.com/users/STRML/gists{/gist_id}","starred_url":"https://api.github.com/users/STRML/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STRML/subscriptions","organizations_url":"https://api.github.com/users/STRML/orgs","repos_url":"https://api.github.com/users/STRML/repos","events_url":"https://api.github.com/users/STRML/events{/privacy}","received_events_url":"https://api.github.com/users/STRML/received_events","type":"User","site_admin":false},"repo":{"id":19760252,"name":"react-localstorage","full_name":"STRML/react-localstorage","owner":{"login":"STRML","id":1197375,"avatar_url":"https://avatars.githubusercontent.com/u/1197375?v=3","gravatar_id":"","url":"https://api.github.com/users/STRML","html_url":"https://github.com/STRML","followers_url":"https://api.github.com/users/STRML/followers","following_url":"https://api.github.com/users/STRML/following{/other_user}","gists_url":"https://api.github.com/users/STRML/gists{/gist_id}","starred_url":"https://api.github.com/users/STRML/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STRML/subscriptions","organizations_url":"https://api.github.com/users/STRML/orgs","repos_url":"https://api.github.com/users/STRML/repos","events_url":"https://api.github.com/users/STRML/events{/privacy}","received_events_url":"https://api.github.com/users/STRML/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/STRML/react-localstorage","description":"Simple componentized localstorage implementation for Facebook's React.","fork":false,"url":"https://api.github.com/repos/STRML/react-localstorage","forks_url":"https://api.github.com/repos/STRML/react-localstorage/forks","keys_url":"https://api.github.com/repos/STRML/react-localstorage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/STRML/react-localstorage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/STRML/react-localstorage/teams","hooks_url":"https://api.github.com/repos/STRML/react-localstorage/hooks","issue_events_url":"https://api.github.com/repos/STRML/react-localstorage/issues/events{/number}","events_url":"https://api.github.com/repos/STRML/react-localstorage/events","assignees_url":"https://api.github.com/repos/STRML/react-localstorage/assignees{/user}","branches_url":"https://api.github.com/repos/STRML/react-localstorage/branches{/branch}","tags_url":"https://api.github.com/repos/STRML/react-localstorage/tags","blobs_url":"https://api.github.com/repos/STRML/react-localstorage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/STRML/react-localstorage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/STRML/react-localstorage/git/refs{/sha}","trees_url":"https://api.github.com/repos/STRML/react-localstorage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/STRML/react-localstorage/statuses/{sha}","languages_url":"https://api.github.com/repos/STRML/react-localstorage/languages","stargazers_url":"https://api.github.com/repos/STRML/react-localstorage/stargazers","contributors_url":"https://api.github.com/repos/STRML/react-localstorage/contributors","subscribers_url":"https://api.github.com/repos/STRML/react-localstorage/subscribers","subscription_url":"https://api.github.com/repos/STRML/react-localstorage/subscription","commits_url":"https://api.github.com/repos/STRML/react-localstorage/commits{/sha}","git_commits_url":"https://api.github.com/repos/STRML/react-localstorage/git/commits{/sha}","comments_url":"https://api.github.com/repos/STRML/react-localstorage/comments{/number}","issue_comment_url":"https://api.github.com/repos/STRML/react-localstorage/issues/comments/{number}","contents_url":"https://api.github.com/repos/STRML/react-localstorage/contents/{+path}","compare_url":"https://api.github.com/repos/STRML/react-localstorage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/STRML/react-localstorage/merges","archive_url":"https://api.github.com/repos/STRML/react-localstorage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/STRML/react-localstorage/downloads","issues_url":"https://api.github.com/repos/STRML/react-localstorage/issues{/number}","pulls_url":"https://api.github.com/repos/STRML/react-localstorage/pulls{/number}","milestones_url":"https://api.github.com/repos/STRML/react-localstorage/milestones{/number}","notifications_url":"https://api.github.com/repos/STRML/react-localstorage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/STRML/react-localstorage/labels{/name}","releases_url":"https://api.github.com/repos/STRML/react-localstorage/releases{/id}","created_at":"2014-05-14T00:05:44Z","updated_at":"2014-12-05T11:19:28Z","pushed_at":"2014-05-14T04:10:22Z","git_url":"git://github.com/STRML/react-localstorage.git","ssh_url":"git@github.com:STRML/react-localstorage.git","clone_url":"https://github.com/STRML/react-localstorage.git","svn_url":"https://github.com/STRML/react-localstorage","homepage":null,"size":108,"stargazers_count":17,"watchers_count":17,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/STRML/react-localstorage/pulls/1"},"html":{"href":"https://github.com/STRML/react-localstorage/pull/1"},"issue":{"href":"https://api.github.com/repos/STRML/react-localstorage/issues/1"},"comments":{"href":"https://api.github.com/repos/STRML/react-localstorage/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/STRML/react-localstorage/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/STRML/react-localstorage/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/STRML/react-localstorage/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/STRML/react-localstorage/statuses/621e9618ec1e7cb28d2834ad4b7d485a4c6fa108"}}}}