Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reactjs外でのDOM操作

chimame
August 18, 2016
220

 Reactjs外でのDOM操作

shinosakarb #24

chimame

August 18, 2016
Tweet

Transcript

  1. ྫ͑͹͜Μͳཁ๬Λ࣮૷͢Δ <marquee height=45 direction=up> ېسΛ൜ͯ͠΋չ͍͸ແ͍ɻ<br /> ͦΕ͚ͩͷ૝͍͕͔֬ʹ༗Δɻ<br /> য͕ΕΔ͜ͷڳͷࢥ͍ΛڰؾͱݺͿͳΒ͹ɺԺ΍͔ͳ ࿀͔͠஌Β͵ݾͷෆጫΛ୰͕͍͍͘ʂ

    </marquee> จࣈΛ্ԼʹࣗಈεΫϩʔϧ͍ͤͨ͞ɻແݶεΫϩʔϧͰද͍ࣔͤͨ͞ɻ ͨͩ͠ɺHTML5Ͱ͸ഇࢭ͕༧ఆ͞Ε͍ͯ·͢ʂ࢖༻͠ͳ͍Α͏ʹʂʂ marqueeλάʹ͸པΕͳ͍ͰͷjQueryͷ ϓϥάΠϯͰ͍͍ײ͡ͷΞχϝʔγϣϯͳ ͍͔ͳʁɹ㱺
  2. ࣮૷ 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>
  3. ࣮૷ʢ࠶ඳըఀࢭ൛ʣ 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"> ࠶ඳըΛͤ͞ͳ͍Α͏ʹ͢Δ͜ͱ͕Մೳ