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
Riot.js in WPD-Week
Search
Tsutomu Kawamura
April 15, 2016
Programming
19
11k
Riot.js in WPD-Week
Reactがメンドクサイ僕らのためのフロントエンド
「RIOT」
http://peatix.com/event/156859/view
Tsutomu Kawamura
April 15, 2016
Tweet
Share
More Decks by Tsutomu Kawamura
See All by Tsutomu Kawamura
Connect your library to the world
cognitom
0
98
JTF2018
cognitom
5
1.2k
Riot: changing on v3 and its companion tools
cognitom
0
120
LLoT Night - Riot.js
cognitom
1
930
Felt - a simple web server with the power of the future
cognitom
0
300
Riot: all about v2 to v3
cognitom
7
3.7k
Create A Small Studio in A Cafe
cognitom
2
890
Riot and Components
cognitom
4
580
Cooking Automation
cognitom
1
540
Other Decks in Programming
See All in Programming
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
103 Early Hints
sugi_0000
1
230
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
190
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
440
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
42 best practices for Symfony, a decade later
tucksaun
1
180
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
260
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
What's in a price? How to price your products and services
michaelherold
243
12k
BBQ
matthewcrist
85
9.4k
Done Done
chrislema
181
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Why Our Code Smells
bkeepers
PRO
335
57k
For a Future-Friendly Web
brad_frost
175
9.4k
Making the Leap to Tech Lead
cromwellryan
133
9k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Designing for Performance
lara
604
68k
The Language of Interfaces
destraynor
154
24k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Transcript
Tsutomu Kawamura @cognitom Librize LLC / OpenSource Cafe, Shimokitazawa React͕ϝϯυΫαΠΒͷͨΊͷϑϩϯτΤϯυ
cognitom
None
HJUIVCDPNDPHOJUPN
ࠓɺ͢͜ͱ
w 3JPUKTͱ w 3JPUͰίϯϙʔωϯτΛॻ͘ w ίϯϙʔωϯτ)5.-෦ w 3JPUΛ͏গ͠ ͍͞͠ લ
ΊΜͲ͍ ޙ w ࠷ۙͷϑϩϯτΤϯυɺͳͥ ϝϯυΫαΠͷ͔ w Ͳ͏͢Δ
ఆΦʔσΟΤϯε
None
3JPUKTͱ
݄WFS
ۙWFS
࠷γϯϓϧͰɺ͍ܰ 6*ϥΠϒϥϦ
খ͍͜͞ͱɺળ
͚ͬ͜͏ਓؾ
ίΞίϛολʔͷډॴ
Կ͕Ͱ͖Δͷ
3FBDU 1PMZNFS 7VF 3JPU "OHVMBS ʜ 6* 'MVY 3FEVY ΄͔֤छ
͋Γ͗͢ ʜ ϑϨʔϜϫʔΫϧʔλ $44 4BTT -&44 #&. 1PTU$44 ʜ $44 3PMMVQ #SPXTFSJGZ 8FC1BDL 4ZTUFN+4 ʜ .PEVMF#VOEMFS HVMQ OQN NBLF HSVOU ʜ λεΫϥϯφʔ &4 5ZQF4DSJQU 'MPX $P⒎FF4DSJQU &4 ʜ ݴޠ &YQSFTT -PPQCBDL 3FMBZ ,PB ʜ αʔόαΠυ LBSNB SFDUBOHVMBS OJHIUNBSF ʜ ςετɾMJOU FTMJOU BWB $ZDMFKT
3FBDU 1PMZNFS 7VF 3JPU "OHVMBS ʜ 6* 'MVY 3FEVY ΄͔֤छ
͋Γ͗͢ ʜ ϑϨʔϜϫʔΫϧʔλ $44 4BTT -&44 #&. 1PTU$44 ʜ $44 3PMMVQ #SPXTFSJGZ 8FC1BDL 4ZTUFN+4 ʜ .PEVMF#VOEMFS HVMQ OQN NBLF HSVOU ʜ λεΫϥϯφʔ &4 5ZQF4DSJQU 'MPX $P⒎FF4DSJQU &4 ʜ ݴޠ &YQSFTT -PPQCBDL 3FMBZ ,PB ʜ αʔόαΠυ LBSNB SFDUBOHVMBS OJHIUNBSF ʜ ςετɾMJOU FTMJOU BWB $ZDMFKT ٕज़ελοΫͷதͷɺίίɻ
ίϯϙʔωϯτΛ࡞Ε·͢ <div> <img src=“clear.svg” /> <ul> <li>ۭΑ͏: Ε</li> <li>ؾԹ: 10</li>
<li>࣪: 30%</li> </ul> </div> <weather type=“clear” temperature=“10” humidity=“30%” /> Ε 10 30%
3JPUKTͲΜͳਓ͚
ʮઆ໌ॻಡ·ͳ͍ਓʯ͚ )5.-ɾ+4ɾ$44Λɺී௨ʹཧղ͍ͯͯ͠
SJPUKTDPNQMBZ ͬͯΈΑ͏
3JPUKTɺ طଘٕज़ͰʮίϯϙʔωϯτʯΛ ࣮ݱ͢ΔͨΊͷɺ࠷γϯϓϧͳ Ξϓϩʔνɻ
͑ͬɺίϯϙʔωϯτͬͯ ผ໊ʮΧελϜλάʯ ͔͋ͨ৽͍͠)5.-ཁૉΛɺ ࣗͰ͖ͳΑ͏ʹఆٛͰ͖ͯ͠·͏ͳʹ͔ɻ
None
3JPUͰίϯϙʔωϯτΛॻ͘
<weather> </weather> HTML JS CSS ఆٛ͢ΔλάͰғΉ͚ͩ weather.tag
<weather> <img src=“clear.svg” /> <ul> <li>ۭΑ͏: { types[opts.type] }</li> <li>ؾԹ:
{ opts.temperature }</li> <li>࣪: { opts.humidity }</li> </ul> <sctipt> this.types = { clear: ‘Ε’ } </script> <style scoped> :scope { display: block; } </style> </weather> HTML JS CSS
<weather> <img src=“clear.svg” /> <ul> <li>ۭΑ͏: { types[opts.type] }</li> <li>ؾԹ:
{ opts.temperature }</li> <li>࣪: { opts.humidity }</li> </ul> <sctipt> this.types = { clear: ‘Ε’ } </script> <style scoped> :scope { display: block; } </style> </weather> HTML JS CSS ͔͗Γͳ͘ɺ)5.-ͦͷͷ
index.html riot.js weather.tag app.tag ϑΝΠϧߏ ˞ͬͱ୯७ͳέʔε
<html> <body> <weather></weather> <script src=“riot.js”></script> <script src=“weather.tag” type=“tag”></script> <script> riot.mount(‘weather’,
{ type: ‘clear’, temperature: 10, humidity: ’30%’ }) </script> <body> </body> Ϛϯτ ͜͜ʹϚϯτ
<html> <body> <app></app> <script src=“riot.js”></script> <script src=“app.tag” type=“tag”></script> <script src=“weather.tag”
type=“tag”></script> <script> riot.mount(‘app’) </script> <body> </body> ؒϚϯτ <app> <weather type=“clear” temperature=“10” humidity=“30%” /> </app> ΄ͱΜͲɺεΫϦϓτΛॻ͔ͳͯ͘ࡁΉ ͜͜ʹϚϯτ
ίʔμʔͷ୲Ͳ͏ͳΔͷ
ैདྷͷॻ͖ํ ਫฏۀ CSS HTML JS Template Template Template
3JPUͷॻ͖ํ ਨ౷߹ CSS HTML JS Template Template Template CSS JS
CSS JS CSS JS Tag A Tag B Tag C
w ෆඞཁʹόϥ͚͍ͯͨͷ͕ɺͻͱͭʹ w )5.-ɾ+4ɾ$44ͦΕͧΕཧղ͍ͯ͠Δඞཁ͋Γ w #&.Αɺ͞Α͏ͳΒ ൣғʮٕज़ʯͰͳ͘ ʮίϯϙʔωϯτʯʹ
None
ίϯϙʔωϯτ)5.-෦
<nandemo-iindayo /> <div> </div>
)5.-ʹ͓͚Δʮؔʯ <weather type=“clear” temperature=“10” humidity=“30%” /> <div> <img src=“clear.svg” />
<ul> <li>ۭΑ͏: Ε</li> <li>ؾԹ: 10</li> <li>࣪: 30%</li> </ul> </div> Ε 10 30%
ίϯϙʔωϯτ㲈XFCDPNQPOFOUT 8FCඪ४ʹ͢Δಈ͖ 3JPU 3FBDU "OHVMBS 1PMZNFS
ਖ਼ɺ͍ͭʹͳΔ͔͔Βͳ͍
ίϯϙʔωϯτWTςϯϓϨʔτ
ίϯϙʔωϯτ ςϯϓϨʔτ )5.-ͷมຒΊࠐΈ :&4 :&4 ΧελϜλάͱͯ͠ৼΔ͏ :&4 /0 ϏϡʔϩδοΫ ϏϡʔͷϦΞϧλΠϜมߋ
:&4 /0 ϏδωεϩδοΫ /0 /0 ίϯϙʔωϯτWTςϯϓϨʔτ ॻ͍ͪΌμϝ
“Templates separate technologies, not concerns.” ʮςϯϓϨʔτ͕Γ͚͍ͯͨͷɺ ͡Όͳٕͯ͘ज़ͩʯ CZ'BDFCPPLͷதͷਓ
Ϗϡʔ ϏδωεϩδοΫ ϏϡʔϩδοΫ Ϗϡʔ ϏδωεϩδοΫ ϏϡʔϩδοΫ ίϯϙʔωϯτ ςϯϓϨʔτ
ίϯϙʔωϯτWTK2VFSZ
ίϯϙʔωϯτWTK2VFSZ )5.-͕ඳը͞ΕΔ Πϕϯτ͕ى͖Δ )5.-͕ඳը͞ΕΔ K2VFSZͰॻ͖͑Δ Πϕϯτ͕ى͖Δ
ίϯϙʔωϯτ K2VFSZ )5.-ͷѻ͍ એݴత ॻ͍ͨ·Μ· ࠩΛૢ࡞ Ͳ͏ม͑Δ͔ σʔλͷྲྀΕ σʔλˠϏϡʔ جຊతʹ
ͪ͝Όͪ͝Ό ίϯϙʔωϯτWTK2VFSZ
None
3JPUΛ͏গ͠
܁Γฦ͠ͱσʔλ <ul> <li>Apple</li> <li>Orange</li> <li>Banana</li> </ul> <ul> <li each={ fruits
}>{ name }</li> </ul> <script> this.fruits = [ { name: ‘Apple’ }, { name: ‘Orange’ }, { name: ‘Banana’ } ] </script>
Πϕϯτϋϯυϥ <input value={ username } onchange={ change }> <script> this.username
= ‘MEGANE’ this.change = e => { username = e.target.value } </script>
4DPQFE$44 <p>WP-D Week</p> <style scoped> :scope { /* ίϯϙʔωϯτͦͷͷͷελΠϧ */
} p { /* ίϯϙʔωϯτͷpλάͷΈʹ༗ޮ */ } </style>
͋ͱɺυΩϡϝϯτݟͯ
None
࠷ۙͷϑϩϯτΤϯυ ͳͥϝϯυΫαΠͷ͔
ϑϩϯτΤϯυ͕͍͠ +BWB4DSJQU͕͍͠
͠͞⁞ จ๏͕ɺશʹϕπϞϊ
ʮͳʜԿΛݴ͍ͬͯΔͷ͔ ɹΘ͔ΒͶʔͱࢥ͏͕ɺ ɹ͓ΕԿΛ͞Εͨͷ͔Θ͔Βͳ͔ͬͨʯ
map(), reduce(), forEach(), some()… for (of), Object.keys() Promise().then() function* (),
yield, async/await const, let, { foo, bar } import foo from ‘foo’, export default foo ͳʹ͜ͷ֎ࠃޠ
͠͞ ςετͱ͔ɺλεΫͱ͔
λεΫϥϯφʔ ςετϦϯλʔ ͦͷଞʜ
͠͞ OQNͱϞδϡʔϧ
ສ ύοέʔδ
import add from ‘./add’ const x = add(1, 2) export
default function add (a, b) { return a + b } ผϑΝΠϧ͔Β ಡΈࠐΊΔ
͠͞ ϙϦϑΟϧͱίϯύΠϧ όϯυϧ
#BCFM #BCFM #BCFM #BCFM #BCFM &4 &4 &4 &4 $ISPNF
4BGBSJ 'JSFGPY &EHF /PEF ϙϦϑΟϧ ࣮લʹػೳΛઌऔΓ
ίϯύΠϧ
͓͢͢Ί όϯυϥʔɺ͍Ζ͍Ζɻ
None
͠͞ ԿʹΓ্͕ͬͯΔͷ͔ Θ͔ΒͶ͑
൙ཞ͢ΔμΠΞάϥϜɺ ܁Γ͛ΒΕΔۭதઓ
੍࣌ΛखʹೖΕͭͭ͋Δ +BWB4DSJQU ࠓேͷ්ͷձ͔Β
چੈքͷ+BWB4DSJQUɺ ͏Ε͍ͯͩ͘͞ɻ ͏·ͬͨ͘ผͷݴޠͰ͢ɻ ʮͨ͠ͳΈʯͱ͔ʮখखઌʯͰͲ͏ʹ͔ͳΔͷͰͳ͘ͳΓ·ͨ͠ɻ
͋Δ͍ʜ ·ͱͳϓϩάϥϜݴޠͱͯ͠ɺ ΘΕΔΑ͏ʹͳͬͨɻ
None
Ͳ͏͢Δ
બࢶ⁞ มԽΛɺָ͠Ή ڧ͍ͯݴ͑ʮΦΠϥʔͷެࣜʯ͕ ൃݟ͞Ε͔ͨͷΑ͏ͳ໘ന͕͞ɺ ࠓͷ+BWB4DSJQUʹ͋Δ
બࢶ ͦͬͱด͡Δ ṷṷɻखग़͞ͳ͍ɻ ޙ͘Β͍ʹɺ͏ҰݟʹདྷΔΑɻ
બࢶ దͳڑײͰ ϑϩϯτͷɺϏϡʔ͚ͩʹݶఆ͢Δɻ K2VFSZఔͷڑײͰ͢Δɻ
3JPUɺ ʮϑϩϯτ͚ͩΔʯ ͱ͍͏બࢶΛఏڙͯ͘͠ΕΔ ʹϑϧελοΫʹͳΓ͗͢ͳ͍
None
5IBOLZPV ࣭ΛͲ͏ͧ