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 がしたい! ...
Search
zoncoen
June 24, 2015
Programming
0
2.1k
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.8k
Perl の HTTP/2 事情 / HTTP2 in Perl
zoncoen
0
470
YAPC::Asia 2014
zoncoen
0
2.7k
同期的にプレゼンテーションするツールをつくった話
zoncoen
1
1k
Gunosy.go #4 ~ flag.go ~ #gunosygo
zoncoen
0
230
Gunosy.go #3 ~ expvar.go ~ #gunosygo
zoncoen
1
740
初心者がGoでpercol実装してみた話 / Golang + Reveal.js + Websocket で同期的にプレゼンテーションしたい #hikarie_go
zoncoen
0
2.6k
Other Decks in Programming
See All in Programming
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
340
タスクの特性や不確実性に応じた最適な作業スタイルの選択(ペアプロ・モブプロ・ソロプロ)と実践 / Optimal Work Style Selection: Pair, Mob, or Solo Programming.
honyanya
3
170
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
230
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
160
ALL CODE BASE ARE BELONG TO STUDY
uzulla
25
6k
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
Six and a half ridiculous things to do with Quarkus
hollycummins
0
170
Go言語はstack overflowの夢を見るか?
logica0419
0
340
Writing Better Go: Lessons from 10 Code Reviews
konradreiche
0
1.3k
CSC305 Lecture 04
javiergs
PRO
0
270
bootcamp2025_バックエンド研修_WebAPIサーバ作成.pdf
geniee_inc
0
110
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
220
Featured
See All Featured
Navigating Team Friction
lara
190
15k
Typedesign – Prime Four
hannesfritz
42
2.8k
Building Better People: How to give real-time feedback that sticks.
wjessup
369
20k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Six Lessons from altMBA
skipperchong
29
4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
980
Git: the NoSQL Database
bkeepers
PRO
431
66k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Scaling GitHub
holman
463
140k
Practical Orchestrator
shlominoach
190
11k
Thoughts on Productivity
jonyablonski
70
4.9k
A Modern Web Designer's Workflow
chriscoyier
697
190k
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