Rendering React Components?

polaris · · 643 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I currently have a Go server that sits in front of a Node.js server whose sole purpose is to render React Components to strings, which it sends back to Go to template and serve. </p> <p>Being a fan of &#34;less moving parts&#34; I was wondering if there was a way to have the Go server do the server-side rendering of the JavaScript instead of needing Node.js in the background?</p> <hr/>**评论:**<br/><br/>shazow: <pre><p>I haven&#39;t done it myself, but take a look at this project: <a href="https://github.com/olebedev/go-starter-kit" rel="nofollow">https://github.com/olebedev/go-starter-kit</a></p></pre>ryokuichigara: <pre><p>Yeah, I looked at this and apparently duktape is a bit behind in terms of performance. While I don&#39;t need a 1:1, it&#39;s apparently a 1:5 on a good day :&lt;</p></pre>mmmmmmmmmmz: <pre><p>For Node.js-like performance rendering React.js templates, I highly recommend using this Go V8 binding: <a href="https://github.com/ry/v8worker" rel="nofollow">https://github.com/ry/v8worker</a></p> <p>The engine used in that starter kit (duktape) is great for getting started quickly because it&#39;s embedded, but performance-wise V8 seems to blow everything else out of the water.</p></pre>ryokuichigara: <pre><p>I actually fan across this as well; I&#39;ll definitely look into it. Thanks for the validation!</p></pre>xyproto: <pre><p>Could Algernon be what you are looking for? It can render JSX to JS and is easy to get started with.</p> <p><a href="https://github.com/xyproto/algernon" rel="nofollow">https://github.com/xyproto/algernon</a></p></pre>ryokuichigara: <pre><p>I&#39;ll definitely look into this, thanks!</p></pre>Fwippy: <pre><p>There&#39;s also <a href="https://github.com/robertkrimen/otto" rel="nofollow">otto</a> for a native Go solution, which might simplify your deployment. It might not be as well optimized as some of the more battle-tested javascript implementations (V8), but it&#39;s probably worth a look.</p></pre>ryokuichigara: <pre><p>Mmkay, I&#39;ll give it a peek, thanks!</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

643 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传