{"action":"opened","issue":{"url":"https://api.github.com/repos/jxnblk/writing/issues/20","labels_url":"https://api.github.com/repos/jxnblk/writing/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/jxnblk/writing/issues/20/comments","events_url":"https://api.github.com/repos/jxnblk/writing/issues/20/events","html_url":"https://github.com/jxnblk/writing/issues/20","id":109922335,"number":20,"title":"Static Site Generation with React and Webpack","user":{"login":"cleechtech","id":3578908,"avatar_url":"https://avatars.githubusercontent.com/u/3578908?v=3","gravatar_id":"","url":"https://api.github.com/users/cleechtech","html_url":"https://github.com/cleechtech","followers_url":"https://api.github.com/users/cleechtech/followers","following_url":"https://api.github.com/users/cleechtech/following{/other_user}","gists_url":"https://api.github.com/users/cleechtech/gists{/gist_id}","starred_url":"https://api.github.com/users/cleechtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cleechtech/subscriptions","organizations_url":"https://api.github.com/users/cleechtech/orgs","repos_url":"https://api.github.com/users/cleechtech/repos","events_url":"https://api.github.com/users/cleechtech/events{/privacy}","received_events_url":"https://api.github.com/users/cleechtech/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-06T02:13:08Z","updated_at":"2015-10-06T02:13:08Z","closed_at":null,"body":"Hi there, Thanks for the tutorial! When using the `safeStringify` function I got:\r\n\r\n```\r\nERROR in TypeError: Converting circular structure to JSON\r\n```\r\n**Root.jsx**\r\n```\r\nvar React = require('react');\r\nvar Router = require('react-router');\r\nvar RouteHandler = Router.RouteHandler;\r\nvar Header = require('./Header.jsx');\r\n\r\nvar Root = React.createClass({\r\n\trender: function(){\r\n\t\tvar initialProps = {\r\n\t\t\t__html: safeStringify(this.props)\r\n\t\t};\r\n\r\n\t\treturn (\r\n\t\t\t<html>\r\n\t\t\t\t<head>\r\n\t\t\t\t\t<title>{this.props.title}</title>\r\n\t\t\t\t</head>\r\n\t\t\t\t<body>\r\n\t\t\t\t\t<Header />\r\n\t\t\t\t\t<RouteHandler {...this.props} />\r\n\t\t\t\t\t<script\r\n\t\t\t\t\t\tid='initial-props'\r\n\t\t\t\t\t\ttype='application/json'\r\n\t\t\t\t\t\tdangerouslySetInnerHTML={initialProps} />\r\n\t\t\t\t\t<script src='bundle.js' />\r\n\t\t\t\t</body>\r\n\t\t\t</html>\r\n\t\t);\r\n\t}\r\n});\r\n\r\n// ERROR in TypeError: Converting circular structure to JSON\r\nfunction safeStringify(obj){\r\n \treturn JSON.stringify(obj).replace(/<\\/script/g, '<\\\\/script').replace(/<!--/g, '<\\\\!--')\r\n}\r\n```\r\n\r\nIf I remove the safeStringify function and pass in `this.props` directly the app will compile and route between Index and About but throws an error in the console:\r\n\r\n<img width=\"1397\" alt=\"screen shot 2015-10-05 at 7 12 12 pm\" src=\"https://cloud.githubusercontent.com/assets/3578908/10298544/1487d434-6b95-11e5-886e-41dcfa9077c0.png\">\r\n\r\n\r\n**entry.js**\r\n\r\n```\r\n// webpack will read this to build bundle.js\r\nvar React = require('react');\r\nvar Router = require('react-router');\r\nvar Routes = require('./Routes.jsx');\r\n\r\n// only run client-side\r\nif(typeof document !== 'undefined'){\r\n\tvar initialProps = JSON.parse(document.getElementById('initial-props').innerHTML);\r\n\tRouter.run(Routes, Router.HistoryLocation, function(Handler){\r\n\t\tReact.render(React.createElement(Handler, initialProps), document);\r\n\t})\r\n}\r\n\r\nmodule.exports = function render(locals, callback){\r\n\tRouter.run(Routes, locals.path, function(Handler){\r\n\t\tvar html = React.renderToString(React.createElement(Handler, locals));\r\n\t\tcallback(null, '<!DOCTYPE html>' + html);\r\n\t})\r\n};\r\n```"}}