Created
February 22, 2018 14:58
-
-
Save itrelease/d65784668bdf5167dde5af45442b9b35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends React.Component { | |
element = null; | |
componentDidMount() { | |
const scriptElements = this.element.querySelectorAll('script'); | |
scriptElements.forEach(sEl => { | |
const scriptEl = document.createElement('script'); | |
const attrs = sEl.attributes; | |
for (let i = 0; i < attrs.length; i += 1) { | |
const { name, value } = attrs[i]; | |
scriptEl.setAttribute(name, value); | |
} | |
sEl.parentElement.replaceChild(scriptEl, sEl); | |
}); | |
} | |
render() { | |
const html = [ | |
'<li><blockquote class="twitter-video" data-lang="en"><p lang="en" dir="ltr">One of the most incredible videos I’ve ever seen! <a href="https://twitter.com/hashtag/Sinabung?src=hash&ref_src=twsrc%5Etfw">#Sinabung</a> <a href="https://twitter.com/hashtag/Sumatra?src=hash&ref_src=twsrc%5Etfw">#Sumatra</a> <a href="https://twitter.com/hashtag/Indonesia?src=hash&ref_src=twsrc%5Etfw">#Indonesia</a> <a href="https://t.co/TsLymrIRJw">pic.twitter.com/TsLymrIRJw</a></p>— UK Weather Live (@UKWeatherLive) <a href="https://twitter.com/UKWeatherLive/status/965485425187082240?ref_src=twsrc%5Etfw">February 19, 2018</a></blockquote><script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></li>', | |
'<li><blockquote class="twitter-video" data-lang="en"><p lang="en" dir="ltr">Huge errupted of Mount Sinabung. <a href="https://t.co/Ood1dGKfS2">pic.twitter.com/Ood1dGKfS2</a></p>— ..e.. (@edykbarus) <a href="https://twitter.com/edykbarus/status/965422919642787840?ref_src=twsrc%5Etfw">February 19, 2018</a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></li>' | |
]; | |
return ( | |
<ul | |
ref={element => { | |
this.element = element; | |
}} | |
dangerouslySetInnerHTML={{ __html: html.join('') }} | |
/> | |
); | |
} | |
} | |
ReactDOM.render(<App />, document.querySelector('#app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment