Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Perl でも React.js の server-side rendering がしたい! / perl meets javascript with reactjs
Search
zoncoen
June 24, 2015
Programming
0
1.8k
Perl でも React.js の server-side rendering がしたい! / perl meets javascript with reactjs
Gotanda.pm#5 LT 資料
zoncoen
June 24, 2015
Tweet
Share
More Decks by zoncoen
See All by zoncoen
About Merpay Engineering Productivity Team
zoncoen
0
1.6k
Perl の HTTP/2 事情 / HTTP2 in Perl
zoncoen
0
410
YAPC::Asia 2014
zoncoen
0
2.6k
同期的にプレゼンテーションするツールをつくった話
zoncoen
1
970
Gunosy.go #4 ~ flag.go ~ #gunosygo
zoncoen
0
220
Gunosy.go #3 ~ expvar.go ~ #gunosygo
zoncoen
1
710
初心者がGoでpercol実装してみた話 / Golang + Reveal.js + Websocket で同期的にプレゼンテーションしたい #hikarie_go
zoncoen
0
2.4k
Other Decks in Programming
See All in Programming
Elm Form Validation
bkuhlmann
0
510
使ってみよう Azure AI Document Intelligence
kosmosebi
2
270
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
170
Rails と人魚の話/rails-and-mermaid
sanfrecce_osaka
0
100
Goのmultiple errorsについて (2024年4月版)
syumai
1
320
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
810
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
210
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
250
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
200
見た目から始める生産性向上
ikumatadokoro
7
750
データアナリストが行うDatabricksを活用したETLの自動化事例
shinoa
0
260
PHPはいつから死んでいるかの調査
chiroruxx
1
360
Featured
See All Featured
Thoughts on Productivity
jonyablonski
57
3.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
16
1.4k
Side Projects
sachag
451
41k
Principles of Awesome APIs and How to Build Them.
keavy
120
16k
How GitHub (no longer) Works
holman
304
140k
In The Pink: A Labor of Love
frogandcode
138
21k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
Producing Creativity
orderedlist
PRO
336
39k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.3k
Being A Developer After 40
akosma
56
580k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
186
16k
Transcript
Perl Ͱ React.js ͷ server-side rendering ͕͍ͨ͠ʂ Gotanda.pm #5 @zoncoen
ͱ͍͏ਓ͍Δ͔͠Εͳ͍ ʢੈք͍ʣ
Ͱ͖ΔΑ
What is React.js • JavaScript view library • Facebook
Why server-side rendering? • ॳظϩʔυ࣌ؒͷվળ • SEO ! React.js ରԠͯ͠Δ
• React.renderToString() • ReactElement ͷ initial HTML Λฦ͢ with Node.js
web server React.renderToString(React.createElement(MyClass, {data: data})); <div data-reactid=".1emne5x67eo" data-react-checksum="154602720"></div>
with other languages • Ruby (on Rails): react-rails ! •
Python: python-react ! → ֤ݴޠ͔Β JavaScript ͷؔΛ࣮ߦ react_component('MyComponent', {data: data}, {prerender: true}) render_component('my-component.jsx', {'data': data}, to_static_markup=true)
Perl ͰΕΔʢͣ | ͖ʣ
How to implement • renderToString() ͷ࣮ߦ݁Ռ͕͋Ε͍͍ → Perl ͔Β JavaScript
ͷؔΛ࣮ߦ
JavaScript::V8 • Perl interface to the V8 JavaScript engine •
Latest version released on 28 Dec 2012 … ! • ͱΓ͋͑ͣ V8 v3.14.5.8 Ͱಈ͘͜ͱΛ֬ೝ
Example #!/usr/bin/env perl use strict; use warnings; use utf8; !
use JavaScript::V8; ! my $context = JavaScript::V8::Context->new(); ! my $result = $context->eval(q| (function () { return 'Hello, JavaScript world!'; })(); |); ! print "$result\n";
Demo https://github.com/zoncoen-sample/reactjs_server-side- rendering_with_perl