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
220
知って得する@cloudflare_vite-pluginのあれこれ
chimame
2
700
Boost Your Web Performance with Hyperdrive
chimame
1
590
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
A better future with KSS
kneath
240
18k
Building Adaptive Systems
keathley
44
3.2k
My Coaching Mixtape
mlcsv
0
350
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
520
Deep Space Network (abreviated)
tonyrice
0
370
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
540
Paper Plane (Part 1)
katiecoart
PRO
2
12k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
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