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
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
190
知って得する@cloudflare_vite-pluginのあれこれ
chimame
2
650
Boost Your Web Performance with Hyperdrive
chimame
1
570
RemixでVersion skewに立ち向かう
chimame
2
1.3k
私がエッジを使う理由
chimame
10
4.2k
GraphQL Server on Edge after that
chimame
1
1.8k
Accelerating App Dev with Cloudflare Workers
chimame
1
510
GraphQL Server on Edge
chimame
12
6.7k
エッジで輝くフロントエンド
chimame
11
7k
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
52k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
640
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
The Curious Case for Waylosing
cassininazir
1
490
Into the Great Unknown - MozCon
thekraken
41
2.7k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Building Adaptive Systems
keathley
44
3.2k
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