Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Reactjs外でのDOM操作
Search
chimame
August 18, 2016
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Reactjs外でのDOM操作
shinosakarb #24
chimame
August 18, 2016
More Decks by chimame
See All by chimame
Cloudflare is Agents
chimame
0
210
知って得する@cloudflare_vite-pluginのあれこれ
chimame
2
690
Boost Your Web Performance with Hyperdrive
chimame
1
580
RemixでVersion skewに立ち向かう
chimame
2
1.3k
私がエッジを使う理由
chimame
10
4.2k
GraphQL Server on Edge after that
chimame
1
1.9k
Accelerating App Dev with Cloudflare Workers
chimame
1
520
GraphQL Server on Edge
chimame
12
6.8k
エッジで輝くフロントエンド
chimame
11
7k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
96
6.9k
For a Future-Friendly Web
brad_frost
183
10k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
480
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
A Soul's Torment
seathinner
8
3.7k
Facilitating Awesome Meetings
lara
57
7.2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
720
A Modern Web Designer's Workflow
chriscoyier
699
190k
A Tale of Four Properties
chriscoyier
163
24k
Rails Girls Zürich Keynote
gr2m
96
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
550
Transcript
ېسɿReactjs֎ͰͷDOMૢ࡞ 2016.08.20 @rito https://github.com/chimame/20160820_lt
ࣗݾհ <Self name="rito" profile="Web engineer" reactjs="1.month" />
–Lezard VALETHɹϨβʔυɾϰΝϨε “ېسΛ൜ͯ͠չ͍ແ͍ɻ ͦΕ͚ͩͷ͍͕͔֬ʹ༗Δɻ য͕ΕΔ͜ͷڳͷࢥ͍ΛڰؾͱݺͿͳΒɺԺ ͔ͳ࿀͔͠Β͵ݾͷෆጫΛ୰͕͍͍͘ʂ” ήʔϜɿϰΝϧΩϦʔϓϩϑΝΠϧΑΓ (c)2013 SQUARE ENIX
CO., LTD.All Rights Reserved.
ྫ͑͜ΜͳཁΛ࣮͢Δ <marquee height=45 direction=up> ېسΛ൜ͯ͠չ͍ແ͍ɻ<br /> ͦΕ͚ͩͷ͍͕͔֬ʹ༗Δɻ<br /> য͕ΕΔ͜ͷڳͷࢥ͍ΛڰؾͱݺͿͳΒɺԺ͔ͳ ࿀͔͠Β͵ݾͷෆጫΛ୰͕͍͍͘ʂ
</marquee> จࣈΛ্ԼʹࣗಈεΫϩʔϧ͍ͤͨ͞ɻແݶεΫϩʔϧͰද͍ࣔͤͨ͞ɻ ͨͩ͠ɺHTML5Ͱഇࢭ͕༧ఆ͞Ε͍ͯ·͢ʂ༻͠ͳ͍Α͏ʹʂʂ marqueeλάʹཔΕͳ͍ͰͷjQueryͷ ϓϥάΠϯͰ͍͍ײ͡ͷΞχϝʔγϣϯͳ ͍͔ͳʁɹ㱺
͍͍ײ͡ͷϓϥάΠϯΛൃݟʂ ېسͱΒͣʹ…
࣮ import React, { Component } from 'react' import $
from 'jquery' import 'jquery.marquee' export default class message extends Component { componentDidUpdate() { $("div.message-body").marquee({direction: 'up'}) $("div.message-body").marquee('resume') } render() { const { message } = this.props return ( <div className=“message-body"> <p style={{whiteSpace: ‘pre’}}> {message} </p> </div>
ॳظදࣔͰ͖ͨɻ ͨͩɺ࠶औಘͯ͠දࣔϝοηʔδ͕มΘͬͯը໘ ͕มΘΒͳ͍ɻ αʔόʢAPIʣ͔Βͷऔಘ͜Μͳײ͡
࣮ࡍʹग़ྗ͞Ε͍ͯΔHTMLιʔεΛݟͯΈΔͱ… ͋ΕʁͳΜ͔Βͳ͍λά͕͍͍ͯΔɻ jQuery.Marquee͕ΞχϝʔγϣϯͷͨΊʹՃ͍ͯ͠Δɻ
ݪҼ ReactjsͰग़ྗͨ࣌͠ͷDOMΛ͍֮͑ͯΔɻ ࠶ඳը͢Δ࣌ग़ྗͨ͠DOM͔Βมߋ෦͚ͩΛআͯ͠৽ͨʹDOMΛग़ྗ͢Δɻ ࠓճͷྫͰɺjQuery.Marquee͕DOMΛॻ͖͑ͯ͠·ͬͨͨΊʹൃੜɻ https://facebook.github.io/react/tips/use-react-with-other-libraries.html ରॲ Ҋ̍ɿ jQuery.Marqueeͷ༻ΛΊɺ࣮Λม͑Δɻ ɹˠjQueryΞχϝʔγϣϯͳΒOK Ҋ̎ɿ
Reactjsͷ࠶ඳըΛࢭΊΔɻ ɹˠ͜ͷҊ࠶ඳը͕ߦ͑ͳ͘ͳΔɻ ཁ݅ͱͷ݉Ͷ߹͍͕ͩɺ”ͦͷ̎”Ͱ͍͍ͳΒ…
–FreyaɹϑϨΠ “ͤΊͯࢲͷखͰ͋ͳͨΛΓʹ͔ͭͤͯ͋͛ΔΘɻ” ήʔϜɿϰΝϧΩϦʔϓϩϑΝΠϧΑΓ (c)2013 SQUARE ENIX CO., LTD.All Rights Reserved.
࣮ʢ࠶ඳըఀࢭ൛ʣ import React, { Component } from 'react' import $
from 'jquery' import 'jquery.marquee' export default class message extends Component { componentDidUpdate() { $("div.message-body").marquee({direction: 'up'}) $("div.message-body").marquee('resume') } shouldComponentUpdate() { return false } render() { const { message } = this.props return ( <div className="message-body"> ࠶ඳըΛͤ͞ͳ͍Α͏ʹ͢Δ͜ͱ͕Մೳ
·ͱΊ • Reactjs֎ͰDOMΛ৮Δͱ࠶ඳըͰ͖ͳ͍ͱߟ͑Δɻ • Reactjs֎ͰDOMΛ৮Δ߹ ɺ”componentDidMount"ͷඳըޙͰ৮Δ͜ͱɻ • ࠶ඳըΛʮߦ͏ʯ͔ʮߦΘͳ͍͔ʯఆ͢Δ” shouldComponentUpdate”ͱ͍͏Lifecycle͕ଘࡏ͢ Δɻ
ͳͷͰͷཁૉҎ֎Ͱ͠ͳ͍Α͏ʹʂʂ
͓·͚ Marquee͜Μͳײ͡Ͱ࡞ͬͯΈ·ͨ͠ɻʢڵຯ͋Εʣ https://gist.github.com/chimame/ 99acd1836992675169f2c705d1fe3209