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
95
JTF2018
cognitom
5
1.2k
Riot: changing on v3 and its companion tools
cognitom
0
110
LLoT Night - Riot.js
cognitom
1
920
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
880
Riot and Components
cognitom
4
580
Cooking Automation
cognitom
1
530
Other Decks in Programming
See All in Programming
現場から考えるソフトウェアエンジニアリングの価値と実験
nomuson
1
130
Hi, have you met Kotlin Multiplatform? | DevFest Vienna 2024
prof18
0
120
Integrating AI in Your Enterprise Java Applications
ivargrimstad
0
240
ビット演算の話 / Let's play with bit operations
kaityo256
PRO
4
180
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
620
実践サーバーレスパフォーマンスチューニング ~その実力に迫る~ / Practical Serverless Performance Tuning ~A Close Look at its Power~
seike460
PRO
2
160
Removing Corepack
yosuke_furukawa
PRO
9
1.2k
CSC509 Lecture 03
javiergs
PRO
0
140
pytest プラグインを開発して DRY に自動テストを書こう
inuatsu
2
260
Beyond Laravel Octane - Hyperf for Laravel Artisans
albertcht
1
140
Vue :: Better Testing 2024
up1
1
400
型付きで行うVSCode拡張機能開発 / VSCode Meetup #31
mazrean
0
240
Featured
See All Featured
Navigating Team Friction
lara
183
14k
Optimizing for Happiness
mojombo
375
69k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
110
6.9k
Building Your Own Lightsaber
phodgson
102
6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
Build The Right Thing And Hit Your Dates
maggiecrowley
31
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
[RailsConf 2023] Rails as a piece of cake
palkan
49
4.7k
Visualization
eitanlees
143
15k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
249
21k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
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 ࣭ΛͲ͏ͧ