{"action":"created","comment":{"url":"https://api.github.com/repos/shakacode/react_on_rails/pulls/comments/46968730","id":46968730,"diff_hunk":"@@ -0,0 +1,277 @@\n+/* eslint-disable no-console */\n+\n+import React from 'react';\n+\n+const context = ((typeof window !== 'undefined') && window) ||\n+  ((typeof global !== 'undefined') && global) || this;\n+\n+let ReactOnRails;\n+\n+const turbolinksInstalled = (typeof Turbolinks !== 'undefined');\n+\n+function provideClientReact() {\n+  if (typeof context.ReactDOM === 'undefined') {\n+    if (React.version >= '0.14') {\n+      console.warn(\n+        'WARNING: ReactDOM is not configured in webpack.server.rails.config.js file as an entry.\\n' +\n+        'See: https://github.com/shakacode/react_on_rails/blob/master/docs/webpack.md for more detailed hints.');\n+    }\n+\n+    return React;\n+  }\n+\n+  return context.ReactDOM;\n+}\n+\n+function provideServerReact() {\n+  if (typeof context.ReactDOMServer === 'undefined') {\n+    if (React.version >= '0.14') {\n+      console.warn(\n+        'WARNING: `react-dom/server` is not configured in webpack.server.rails.config.js file as an entry.\\n' +\n+        'See: https://github.com/shakacode/react_on_rails/blob/master/docs/webpack.md for more detailed hints.');\n+    }\n+\n+    return context.React;\n+  }\n+\n+  return context.ReactDOMServer;\n+}\n+\n+function wrapInScriptTags(scriptBody) {\n+  if (!scriptBody) {\n+    return '';\n+  }\n+\n+  return '\\n<script>' + scriptBody + '\\n</script>';\n+}\n+\n+function forEachComponent(fn) {\n+  const els = document.getElementsByClassName('js-react-on-rails-component');\n+  for (let i = 0; i < els.length; i++) {\n+    fn(els[i]);\n+  }\n+}\n+\n+function unmount(el) {\n+  const domId = el.getAttribute('data-dom-id');\n+  const domNode = document.getElementById(domId);\n+  provideClientReact().unmountComponentAtNode(domNode);\n+}\n+\n+function isRouterResult(reactElementOrRouterResult) {\n+  return !!(reactElementOrRouterResult.redirectLocation ||\n+  reactElementOrRouterResult.error);\n+}\n+\n+function createReactElementOrRouterResult(componentName, props, domId, trace, generatorFunction, location) {\n+  if (trace) {\n+    console.log('RENDERED ' + componentName + ' to dom node with id: ' + domId);\n+  }\n+\n+  const component = ReactOnRails.componentForName(componentName);\n+  if (generatorFunction) {\n+    return component(props, location);\n+  }\n+\n+  return React.createElement(component, props);\n+}\n+\n+function render(el) {\n+  const componentName = el.getAttribute('data-component-name');\n+  const domId = el.getAttribute('data-dom-id');\n+  const props = JSON.parse(el.getAttribute('data-props'));\n+  const trace = JSON.parse(el.getAttribute('data-trace'));\n+  const generatorFunction = JSON.parse(el.getAttribute('data-generator-function'));\n+  const expectTurboLinks = JSON.parse(el.getAttribute('data-expect-turbo-links'));\n+\n+  if (!turbolinksInstalled && expectTurboLinks) {\n+    console.warn('WARNING: NO TurboLinks detected in JS, but it is in your Gemfile');\n+  }\n+\n+  try {\n+    const domNode = document.getElementById(domId);\n+    if (domNode) {\n+      const reactElementOrRouterResult = createReactElementOrRouterResult(componentName, props,\n+        domId, trace, generatorFunction);\n+      if (isRouterResult(reactElementOrRouterResult)) {\n+        throw new Error('You returned a server side type of react-router error: ' +\n+          JSON.stringify(reactElementOrRouterResult) +\n+          '\\nYou should return a React.Component always for the client side entry point.');\n+      } else {\n+        provideClientReact().render(reactElementOrRouterResult, domNode);\n+      }\n+    }\n+  } catch (e) {\n+    ReactOnRails.handleError({\n+      e: e,\n+      componentName: componentName,\n+      serverSide: false,\n+    });\n+  }\n+}\n+\n+function reactOnRailsPageLoaded() {\n+  forEachComponent(render);\n+}\n+\n+function reactOnRailsPageUnloaded() {\n+  forEachComponent(unmount);\n+}\n+\n+const components = {};","path":"node_package/src/react_on_rails.js","position":121,"original_position":121,"commit_id":"bfc13fb7122eb86ddeb2d767a16dd0b53bf8c109","original_commit_id":"bfc13fb7122eb86ddeb2d767a16dd0b53bf8c109","user":{"login":"yorzi","id":38976,"avatar_url":"https://avatars.githubusercontent.com/u/38976?v=3","gravatar_id":"","url":"https://api.github.com/users/yorzi","html_url":"https://github.com/yorzi","followers_url":"https://api.github.com/users/yorzi/followers","following_url":"https://api.github.com/users/yorzi/following{/other_user}","gists_url":"https://api.github.com/users/yorzi/gists{/gist_id}","starred_url":"https://api.github.com/users/yorzi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yorzi/subscriptions","organizations_url":"https://api.github.com/users/yorzi/orgs","repos_url":"https://api.github.com/users/yorzi/repos","events_url":"https://api.github.com/users/yorzi/events{/privacy}","received_events_url":"https://api.github.com/users/yorzi/received_events","type":"User","site_admin":false},"body":"I can not understand this variable here. If we attach components to this `components ` const, how should it work? (comparing to previous window.component_name or global.component_name) cc @justin808 @alexfedoseev ","created_at":"2015-12-08T15:41:28Z","updated_at":"2015-12-08T15:41:28Z","html_url":"https://github.com/shakacode/react_on_rails/pull/148#discussion_r46968730","pull_request_url":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148","_links":{"self":{"href":"https://api.github.com/repos/shakacode/react_on_rails/pulls/comments/46968730"},"html":{"href":"https://github.com/shakacode/react_on_rails/pull/148#discussion_r46968730"},"pull_request":{"href":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148"}}},"pull_request":{"url":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148","id":52810117,"html_url":"https://github.com/shakacode/react_on_rails/pull/148","diff_url":"https://github.com/shakacode/react_on_rails/pull/148.diff","patch_url":"https://github.com/shakacode/react_on_rails/pull/148.patch","issue_url":"https://api.github.com/repos/shakacode/react_on_rails/issues/148","number":148,"state":"open","locked":false,"title":"WIP -- conversion to ES6, npm for react_on_rails","user":{"login":"justin808","id":1118459,"avatar_url":"https://avatars.githubusercontent.com/u/1118459?v=3","gravatar_id":"","url":"https://api.github.com/users/justin808","html_url":"https://github.com/justin808","followers_url":"https://api.github.com/users/justin808/followers","following_url":"https://api.github.com/users/justin808/following{/other_user}","gists_url":"https://api.github.com/users/justin808/gists{/gist_id}","starred_url":"https://api.github.com/users/justin808/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justin808/subscriptions","organizations_url":"https://api.github.com/users/justin808/orgs","repos_url":"https://api.github.com/users/justin808/repos","events_url":"https://api.github.com/users/justin808/events{/privacy}","received_events_url":"https://api.github.com/users/justin808/received_events","type":"User","site_admin":false},"body":"* fixed linting issues\r\n* could not start spec/dummy due to bundler errors\r\n\r\nSee #128","created_at":"2015-12-07T06:36:55Z","updated_at":"2015-12-08T15:41:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3bd3e1551440fe4084c1b281fa87e993368a15cb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148/commits","review_comments_url":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148/comments","review_comment_url":"https://api.github.com/repos/shakacode/react_on_rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shakacode/react_on_rails/issues/148/comments","statuses_url":"https://api.github.com/repos/shakacode/react_on_rails/statuses/bfc13fb7122eb86ddeb2d767a16dd0b53bf8c109","head":{"label":"shakacode:npm-react-on-rails-js","ref":"npm-react-on-rails-js","sha":"bfc13fb7122eb86ddeb2d767a16dd0b53bf8c109","user":{"login":"shakacode","id":13779463,"avatar_url":"https://avatars.githubusercontent.com/u/13779463?v=3","gravatar_id":"","url":"https://api.github.com/users/shakacode","html_url":"https://github.com/shakacode","followers_url":"https://api.github.com/users/shakacode/followers","following_url":"https://api.github.com/users/shakacode/following{/other_user}","gists_url":"https://api.github.com/users/shakacode/gists{/gist_id}","starred_url":"https://api.github.com/users/shakacode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shakacode/subscriptions","organizations_url":"https://api.github.com/users/shakacode/orgs","repos_url":"https://api.github.com/users/shakacode/repos","events_url":"https://api.github.com/users/shakacode/events{/privacy}","received_events_url":"https://api.github.com/users/shakacode/received_events","type":"Organization","site_admin":false},"repo":{"id":41117523,"name":"react_on_rails","full_name":"shakacode/react_on_rails","owner":{"login":"shakacode","id":13779463,"avatar_url":"https://avatars.githubusercontent.com/u/13779463?v=3","gravatar_id":"","url":"https://api.github.com/users/shakacode","html_url":"https://github.com/shakacode","followers_url":"https://api.github.com/users/shakacode/followers","following_url":"https://api.github.com/users/shakacode/following{/other_user}","gists_url":"https://api.github.com/users/shakacode/gists{/gist_id}","starred_url":"https://api.github.com/users/shakacode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shakacode/subscriptions","organizations_url":"https://api.github.com/users/shakacode/orgs","repos_url":"https://api.github.com/users/shakacode/repos","events_url":"https://api.github.com/users/shakacode/events{/privacy}","received_events_url":"https://api.github.com/users/shakacode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shakacode/react_on_rails","description":"Integration of React + Webpack + Rails to build Universal (Isomorphic) Apps","fork":false,"url":"https://api.github.com/repos/shakacode/react_on_rails","forks_url":"https://api.github.com/repos/shakacode/react_on_rails/forks","keys_url":"https://api.github.com/repos/shakacode/react_on_rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shakacode/react_on_rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shakacode/react_on_rails/teams","hooks_url":"https://api.github.com/repos/shakacode/react_on_rails/hooks","issue_events_url":"https://api.github.com/repos/shakacode/react_on_rails/issues/events{/number}","events_url":"https://api.github.com/repos/shakacode/react_on_rails/events","assignees_url":"https://api.github.com/repos/shakacode/react_on_rails/assignees{/user}","branches_url":"https://api.github.com/repos/shakacode/react_on_rails/branches{/branch}","tags_url":"https://api.github.com/repos/shakacode/react_on_rails/tags","blobs_url":"https://api.github.com/repos/shakacode/react_on_rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shakacode/react_on_rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shakacode/react_on_rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/shakacode/react_on_rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shakacode/react_on_rails/statuses/{sha}","languages_url":"https://api.github.com/repos/shakacode/react_on_rails/languages","stargazers_url":"https://api.github.com/repos/shakacode/react_on_rails/stargazers","contributors_url":"https://api.github.com/repos/shakacode/react_on_rails/contributors","subscribers_url":"https://api.github.com/repos/shakacode/react_on_rails/subscribers","subscription_url":"https://api.github.com/repos/shakacode/react_on_rails/subscription","commits_url":"https://api.github.com/repos/shakacode/react_on_rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/shakacode/react_on_rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/shakacode/react_on_rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/shakacode/react_on_rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/shakacode/react_on_rails/contents/{+path}","compare_url":"https://api.github.com/repos/shakacode/react_on_rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shakacode/react_on_rails/merges","archive_url":"https://api.github.com/repos/shakacode/react_on_rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shakacode/react_on_rails/downloads","issues_url":"https://api.github.com/repos/shakacode/react_on_rails/issues{/number}","pulls_url":"https://api.github.com/repos/shakacode/react_on_rails/pulls{/number}","milestones_url":"https://api.github.com/repos/shakacode/react_on_rails/milestones{/number}","notifications_url":"https://api.github.com/repos/shakacode/react_on_rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shakacode/react_on_rails/labels{/name}","releases_url":"https://api.github.com/repos/shakacode/react_on_rails/releases{/id}","created_at":"2015-08-20T20:31:54Z","updated_at":"2015-12-08T14:40:31Z","pushed_at":"2015-12-08T15:34:41Z","git_url":"git://github.com/shakacode/react_on_rails.git","ssh_url":"git@github.com:shakacode/react_on_rails.git","clone_url":"https://github.com/shakacode/react_on_rails.git","svn_url":"https://github.com/shakacode/react_on_rails","homepage":null,"size":828,"stargazers_count":448,"watchers_count":448,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":16,"forks":33,"open_issues":16,"watchers":448,"default_branch":"master"}},"base":{"label":"shakacode:master","ref":"master","sha":"d845b521d681364bbb7823c140a917c880fe260a","user":{"login":"shakacode","id":13779463,"avatar_url":"https://avatars.githubusercontent.com/u/13779463?v=3","gravatar_id":"","url":"https://api.github.com/users/shakacode","html_url":"https://github.com/shakacode","followers_url":"https://api.github.com/users/shakacode/followers","following_url":"https://api.github.com/users/shakacode/following{/other_user}","gists_url":"https://api.github.com/users/shakacode/gists{/gist_id}","starred_url":"https://api.github.com/users/shakacode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shakacode/subscriptions","organizations_url":"https://api.github.com/users/shakacode/orgs","repos_url":"https://api.github.com/users/shakacode/repos","events_url":"https://api.github.com/users/shakacode/events{/privacy}","received_events_url":"https://api.github.com/users/shakacode/received_events","type":"Organization","site_admin":false},"repo":{"id":41117523,"name":"react_on_rails","full_name":"shakacode/react_on_rails","owner":{"login":"shakacode","id":13779463,"avatar_url":"https://avatars.githubusercontent.com/u/13779463?v=3","gravatar_id":"","url":"https://api.github.com/users/shakacode","html_url":"https://github.com/shakacode","followers_url":"https://api.github.com/users/shakacode/followers","following_url":"https://api.github.com/users/shakacode/following{/other_user}","gists_url":"https://api.github.com/users/shakacode/gists{/gist_id}","starred_url":"https://api.github.com/users/shakacode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shakacode/subscriptions","organizations_url":"https://api.github.com/users/shakacode/orgs","repos_url":"https://api.github.com/users/shakacode/repos","events_url":"https://api.github.com/users/shakacode/events{/privacy}","received_events_url":"https://api.github.com/users/shakacode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shakacode/react_on_rails","description":"Integration of React + Webpack + Rails to build Universal (Isomorphic) Apps","fork":false,"url":"https://api.github.com/repos/shakacode/react_on_rails","forks_url":"https://api.github.com/repos/shakacode/react_on_rails/forks","keys_url":"https://api.github.com/repos/shakacode/react_on_rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shakacode/react_on_rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shakacode/react_on_rails/teams","hooks_url":"https://api.github.com/repos/shakacode/react_on_rails/hooks","issue_events_url":"https://api.github.com/repos/shakacode/react_on_rails/issues/events{/number}","events_url":"https://api.github.com/repos/shakacode/react_on_rails/events","assignees_url":"https://api.github.com/repos/shakacode/react_on_rails/assignees{/user}","branches_url":"https://api.github.com/repos/shakacode/react_on_rails/branches{/branch}","tags_url":"https://api.github.com/repos/shakacode/react_on_rails/tags","blobs_url":"https://api.github.com/repos/shakacode/react_on_rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shakacode/react_on_rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shakacode/react_on_rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/shakacode/react_on_rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shakacode/react_on_rails/statuses/{sha}","languages_url":"https://api.github.com/repos/shakacode/react_on_rails/languages","stargazers_url":"https://api.github.com/repos/shakacode/react_on_rails/stargazers","contributors_url":"https://api.github.com/repos/shakacode/react_on_rails/contributors","subscribers_url":"https://api.github.com/repos/shakacode/react_on_rails/subscribers","subscription_url":"https://api.github.com/repos/shakacode/react_on_rails/subscription","commits_url":"https://api.github.com/repos/shakacode/react_on_rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/shakacode/react_on_rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/shakacode/react_on_rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/shakacode/react_on_rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/shakacode/react_on_rails/contents/{+path}","compare_url":"https://api.github.com/repos/shakacode/react_on_rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shakacode/react_on_rails/merges","archive_url":"https://api.github.com/repos/shakacode/react_on_rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shakacode/react_on_rails/downloads","issues_url":"https://api.github.com/repos/shakacode/react_on_rails/issues{/number}","pulls_url":"https://api.github.com/repos/shakacode/react_on_rails/pulls{/number}","milestones_url":"https://api.github.com/repos/shakacode/react_on_rails/milestones{/number}","notifications_url":"https://api.github.com/repos/shakacode/react_on_rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shakacode/react_on_rails/labels{/name}","releases_url":"https://api.github.com/repos/shakacode/react_on_rails/releases{/id}","created_at":"2015-08-20T20:31:54Z","updated_at":"2015-12-08T14:40:31Z","pushed_at":"2015-12-08T15:34:41Z","git_url":"git://github.com/shakacode/react_on_rails.git","ssh_url":"git@github.com:shakacode/react_on_rails.git","clone_url":"https://github.com/shakacode/react_on_rails.git","svn_url":"https://github.com/shakacode/react_on_rails","homepage":null,"size":828,"stargazers_count":448,"watchers_count":448,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":16,"forks":33,"open_issues":16,"watchers":448,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148"},"html":{"href":"https://github.com/shakacode/react_on_rails/pull/148"},"issue":{"href":"https://api.github.com/repos/shakacode/react_on_rails/issues/148"},"comments":{"href":"https://api.github.com/repos/shakacode/react_on_rails/issues/148/comments"},"review_comments":{"href":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148/comments"},"review_comment":{"href":"https://api.github.com/repos/shakacode/react_on_rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shakacode/react_on_rails/pulls/148/commits"},"statuses":{"href":"https://api.github.com/repos/shakacode/react_on_rails/statuses/bfc13fb7122eb86ddeb2d767a16dd0b53bf8c109"}}}}