{"action":"created","comment":{"url":"https://api.github.com/repos/vector-im/vector-web/pulls/comments/43524720","id":43524720,"diff_hunk":"@@ -21,6 +21,22 @@ var React = require('react');\n module.exports = React.createClass({\n     displayName: 'ViewSource',\n \n+    componentDidMount: function() {\n+        document.addEventListener(\"keydown\", this.onKeyDown);\n+    },\n+\n+    componentWillUnmount: function() {\n+        document.removeEventListener(\"keydown\", this.onKeyDown);\n+    },\n+\n+    onKeyDown: function(ev) {\n+        if (ev.keyCode == 27) { // escape\n+            ev.stopPropagation();\n+            ev.preventDefault();\n+            this.props.onFinished();","path":"src/skins/vector/views/organisms/ViewSource.js","position":16,"original_position":16,"commit_id":"ffb9ce89c78ab91e3b37625548448d9461c2f0a2","original_commit_id":"ffb9ce89c78ab91e3b37625548448d9461c2f0a2","user":{"login":"Kegsay","id":7190048,"avatar_url":"https://avatars.githubusercontent.com/u/7190048?v=3","gravatar_id":"","url":"https://api.github.com/users/Kegsay","html_url":"https://github.com/Kegsay","followers_url":"https://api.github.com/users/Kegsay/followers","following_url":"https://api.github.com/users/Kegsay/following{/other_user}","gists_url":"https://api.github.com/users/Kegsay/gists{/gist_id}","starred_url":"https://api.github.com/users/Kegsay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kegsay/subscriptions","organizations_url":"https://api.github.com/users/Kegsay/orgs","repos_url":"https://api.github.com/users/Kegsay/repos","events_url":"https://api.github.com/users/Kegsay/events{/privacy}","received_events_url":"https://api.github.com/users/Kegsay/received_events","type":"User","site_admin":false},"body":"This is an ongoing problem I have with react/vector split which makes this line here *really* non-obvious. This will crash if `onFinished` is not passed as a prop (undefined is not a function). The class isn't saying it accepts this prop. There are no default props. React SDK *may* be supplying the prop (it isn't in this case). I have no idea **what** uses this at all, which makes refactoring Really Hard. I would prefer that:\r\n - The props the class uses are explicitly defined.\r\n - There are default prop implementations for optional props.\r\n\r\nThis in practice means adding:\r\n\r\n```javascript\r\nmodule.exports = React.createClass({\r\n [...]\r\n\r\n  propTypes: {\r\n    onFinished: React.PropTypes.func // adding .isRequired if this is a required prop in which case don't bother with a default prop\r\n  },\r\n\r\n  getDefaultProps: function() {\r\n    return {\r\n      onFinished: function() {} // nop\r\n    }\r\n  },\r\n\r\n  [...]\r\n}\r\n```\r\n\r\nWe don't do this currently everywhere, but I would really like to be in a place where we can have some confidence that certain methods exist.","created_at":"2015-10-30T16:47:29Z","updated_at":"2015-10-30T16:47:29Z","html_url":"https://github.com/vector-im/vector-web/pull/296#discussion_r43524720","pull_request_url":"https://api.github.com/repos/vector-im/vector-web/pulls/296","_links":{"self":{"href":"https://api.github.com/repos/vector-im/vector-web/pulls/comments/43524720"},"html":{"href":"https://github.com/vector-im/vector-web/pull/296#discussion_r43524720"},"pull_request":{"href":"https://api.github.com/repos/vector-im/vector-web/pulls/296"}}},"pull_request":{"url":"https://api.github.com/repos/vector-im/vector-web/pulls/296","id":49257986,"html_url":"https://github.com/vector-im/vector-web/pull/296","diff_url":"https://github.com/vector-im/vector-web/pull/296.diff","patch_url":"https://github.com/vector-im/vector-web/pull/296.patch","issue_url":"https://api.github.com/repos/vector-im/vector-web/issues/296","number":296,"state":"open","locked":false,"title":"Matthew/redesign","user":{"login":"dbkr","id":986903,"avatar_url":"https://avatars.githubusercontent.com/u/986903?v=3","gravatar_id":"","url":"https://api.github.com/users/dbkr","html_url":"https://github.com/dbkr","followers_url":"https://api.github.com/users/dbkr/followers","following_url":"https://api.github.com/users/dbkr/following{/other_user}","gists_url":"https://api.github.com/users/dbkr/gists{/gist_id}","starred_url":"https://api.github.com/users/dbkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbkr/subscriptions","organizations_url":"https://api.github.com/users/dbkr/orgs","repos_url":"https://api.github.com/users/dbkr/repos","events_url":"https://api.github.com/users/dbkr/events{/privacy}","received_events_url":"https://api.github.com/users/dbkr/received_events","type":"User","site_admin":false},"body":"Matthew's redesign branch of doom","created_at":"2015-10-30T11:25:08Z","updated_at":"2015-10-30T16:47:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df86a07d0de74133ec64e75ba154a536f1a026c6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vector-im/vector-web/pulls/296/commits","review_comments_url":"https://api.github.com/repos/vector-im/vector-web/pulls/296/comments","review_comment_url":"https://api.github.com/repos/vector-im/vector-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vector-im/vector-web/issues/296/comments","statuses_url":"https://api.github.com/repos/vector-im/vector-web/statuses/ffb9ce89c78ab91e3b37625548448d9461c2f0a2","head":{"label":"vector-im:matthew/redesign","ref":"matthew/redesign","sha":"ffb9ce89c78ab91e3b37625548448d9461c2f0a2","user":{"login":"vector-im","id":13446337,"avatar_url":"https://avatars.githubusercontent.com/u/13446337?v=3","gravatar_id":"","url":"https://api.github.com/users/vector-im","html_url":"https://github.com/vector-im","followers_url":"https://api.github.com/users/vector-im/followers","following_url":"https://api.github.com/users/vector-im/following{/other_user}","gists_url":"https://api.github.com/users/vector-im/gists{/gist_id}","starred_url":"https://api.github.com/users/vector-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vector-im/subscriptions","organizations_url":"https://api.github.com/users/vector-im/orgs","repos_url":"https://api.github.com/users/vector-im/repos","events_url":"https://api.github.com/users/vector-im/events{/privacy}","received_events_url":"https://api.github.com/users/vector-im/received_events","type":"Organization","site_admin":false},"repo":{"id":39487546,"name":"vector-web","full_name":"vector-im/vector-web","owner":{"login":"vector-im","id":13446337,"avatar_url":"https://avatars.githubusercontent.com/u/13446337?v=3","gravatar_id":"","url":"https://api.github.com/users/vector-im","html_url":"https://github.com/vector-im","followers_url":"https://api.github.com/users/vector-im/followers","following_url":"https://api.github.com/users/vector-im/following{/other_user}","gists_url":"https://api.github.com/users/vector-im/gists{/gist_id}","starred_url":"https://api.github.com/users/vector-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vector-im/subscriptions","organizations_url":"https://api.github.com/users/vector-im/orgs","repos_url":"https://api.github.com/users/vector-im/repos","events_url":"https://api.github.com/users/vector-im/events{/privacy}","received_events_url":"https://api.github.com/users/vector-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vector-im/vector-web","description":"Vector collaboration client","fork":false,"url":"https://api.github.com/repos/vector-im/vector-web","forks_url":"https://api.github.com/repos/vector-im/vector-web/forks","keys_url":"https://api.github.com/repos/vector-im/vector-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vector-im/vector-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vector-im/vector-web/teams","hooks_url":"https://api.github.com/repos/vector-im/vector-web/hooks","issue_events_url":"https://api.github.com/repos/vector-im/vector-web/issues/events{/number}","events_url":"https://api.github.com/repos/vector-im/vector-web/events","assignees_url":"https://api.github.com/repos/vector-im/vector-web/assignees{/user}","branches_url":"https://api.github.com/repos/vector-im/vector-web/branches{/branch}","tags_url":"https://api.github.com/repos/vector-im/vector-web/tags","blobs_url":"https://api.github.com/repos/vector-im/vector-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vector-im/vector-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vector-im/vector-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/vector-im/vector-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vector-im/vector-web/statuses/{sha}","languages_url":"https://api.github.com/repos/vector-im/vector-web/languages","stargazers_url":"https://api.github.com/repos/vector-im/vector-web/stargazers","contributors_url":"https://api.github.com/repos/vector-im/vector-web/contributors","subscribers_url":"https://api.github.com/repos/vector-im/vector-web/subscribers","subscription_url":"https://api.github.com/repos/vector-im/vector-web/subscription","commits_url":"https://api.github.com/repos/vector-im/vector-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/vector-im/vector-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/vector-im/vector-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/vector-im/vector-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/vector-im/vector-web/contents/{+path}","compare_url":"https://api.github.com/repos/vector-im/vector-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vector-im/vector-web/merges","archive_url":"https://api.github.com/repos/vector-im/vector-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vector-im/vector-web/downloads","issues_url":"https://api.github.com/repos/vector-im/vector-web/issues{/number}","pulls_url":"https://api.github.com/repos/vector-im/vector-web/pulls{/number}","milestones_url":"https://api.github.com/repos/vector-im/vector-web/milestones{/number}","notifications_url":"https://api.github.com/repos/vector-im/vector-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vector-im/vector-web/labels{/name}","releases_url":"https://api.github.com/repos/vector-im/vector-web/releases{/id}","created_at":"2015-07-22T05:32:15Z","updated_at":"2015-10-27T02:14:16Z","pushed_at":"2015-10-30T14:59:07Z","git_url":"git://github.com/vector-im/vector-web.git","ssh_url":"git@github.com:vector-im/vector-web.git","clone_url":"https://github.com/vector-im/vector-web.git","svn_url":"https://github.com/vector-im/vector-web","homepage":"http://vector.im","size":2702,"stargazers_count":33,"watchers_count":33,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":216,"forks":9,"open_issues":216,"watchers":33,"default_branch":"master"}},"base":{"label":"vector-im:develop","ref":"develop","sha":"f4ca30bb381c418abd76ab39315f20d29c7fd6d1","user":{"login":"vector-im","id":13446337,"avatar_url":"https://avatars.githubusercontent.com/u/13446337?v=3","gravatar_id":"","url":"https://api.github.com/users/vector-im","html_url":"https://github.com/vector-im","followers_url":"https://api.github.com/users/vector-im/followers","following_url":"https://api.github.com/users/vector-im/following{/other_user}","gists_url":"https://api.github.com/users/vector-im/gists{/gist_id}","starred_url":"https://api.github.com/users/vector-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vector-im/subscriptions","organizations_url":"https://api.github.com/users/vector-im/orgs","repos_url":"https://api.github.com/users/vector-im/repos","events_url":"https://api.github.com/users/vector-im/events{/privacy}","received_events_url":"https://api.github.com/users/vector-im/received_events","type":"Organization","site_admin":false},"repo":{"id":39487546,"name":"vector-web","full_name":"vector-im/vector-web","owner":{"login":"vector-im","id":13446337,"avatar_url":"https://avatars.githubusercontent.com/u/13446337?v=3","gravatar_id":"","url":"https://api.github.com/users/vector-im","html_url":"https://github.com/vector-im","followers_url":"https://api.github.com/users/vector-im/followers","following_url":"https://api.github.com/users/vector-im/following{/other_user}","gists_url":"https://api.github.com/users/vector-im/gists{/gist_id}","starred_url":"https://api.github.com/users/vector-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vector-im/subscriptions","organizations_url":"https://api.github.com/users/vector-im/orgs","repos_url":"https://api.github.com/users/vector-im/repos","events_url":"https://api.github.com/users/vector-im/events{/privacy}","received_events_url":"https://api.github.com/users/vector-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vector-im/vector-web","description":"Vector collaboration client","fork":false,"url":"https://api.github.com/repos/vector-im/vector-web","forks_url":"https://api.github.com/repos/vector-im/vector-web/forks","keys_url":"https://api.github.com/repos/vector-im/vector-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vector-im/vector-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vector-im/vector-web/teams","hooks_url":"https://api.github.com/repos/vector-im/vector-web/hooks","issue_events_url":"https://api.github.com/repos/vector-im/vector-web/issues/events{/number}","events_url":"https://api.github.com/repos/vector-im/vector-web/events","assignees_url":"https://api.github.com/repos/vector-im/vector-web/assignees{/user}","branches_url":"https://api.github.com/repos/vector-im/vector-web/branches{/branch}","tags_url":"https://api.github.com/repos/vector-im/vector-web/tags","blobs_url":"https://api.github.com/repos/vector-im/vector-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vector-im/vector-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vector-im/vector-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/vector-im/vector-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vector-im/vector-web/statuses/{sha}","languages_url":"https://api.github.com/repos/vector-im/vector-web/languages","stargazers_url":"https://api.github.com/repos/vector-im/vector-web/stargazers","contributors_url":"https://api.github.com/repos/vector-im/vector-web/contributors","subscribers_url":"https://api.github.com/repos/vector-im/vector-web/subscribers","subscription_url":"https://api.github.com/repos/vector-im/vector-web/subscription","commits_url":"https://api.github.com/repos/vector-im/vector-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/vector-im/vector-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/vector-im/vector-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/vector-im/vector-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/vector-im/vector-web/contents/{+path}","compare_url":"https://api.github.com/repos/vector-im/vector-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vector-im/vector-web/merges","archive_url":"https://api.github.com/repos/vector-im/vector-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vector-im/vector-web/downloads","issues_url":"https://api.github.com/repos/vector-im/vector-web/issues{/number}","pulls_url":"https://api.github.com/repos/vector-im/vector-web/pulls{/number}","milestones_url":"https://api.github.com/repos/vector-im/vector-web/milestones{/number}","notifications_url":"https://api.github.com/repos/vector-im/vector-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vector-im/vector-web/labels{/name}","releases_url":"https://api.github.com/repos/vector-im/vector-web/releases{/id}","created_at":"2015-07-22T05:32:15Z","updated_at":"2015-10-27T02:14:16Z","pushed_at":"2015-10-30T14:59:07Z","git_url":"git://github.com/vector-im/vector-web.git","ssh_url":"git@github.com:vector-im/vector-web.git","clone_url":"https://github.com/vector-im/vector-web.git","svn_url":"https://github.com/vector-im/vector-web","homepage":"http://vector.im","size":2702,"stargazers_count":33,"watchers_count":33,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":216,"forks":9,"open_issues":216,"watchers":33,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vector-im/vector-web/pulls/296"},"html":{"href":"https://github.com/vector-im/vector-web/pull/296"},"issue":{"href":"https://api.github.com/repos/vector-im/vector-web/issues/296"},"comments":{"href":"https://api.github.com/repos/vector-im/vector-web/issues/296/comments"},"review_comments":{"href":"https://api.github.com/repos/vector-im/vector-web/pulls/296/comments"},"review_comment":{"href":"https://api.github.com/repos/vector-im/vector-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vector-im/vector-web/pulls/296/commits"},"statuses":{"href":"https://api.github.com/repos/vector-im/vector-web/statuses/ffb9ce89c78ab91e3b37625548448d9461c2f0a2"}}}}