facebookarchive / react-page

Easy Application Development with React JavaScript
Apache License 2.0
797 stars 72 forks source link

Better support for <script> #42

Closed vjeux closed 10 years ago

vjeux commented 10 years ago

&lt;script> is a bit hard to use right now.

In order to workaround those two issues the best way I found is to use dangerouslySetInnerHTML and use ES6 backtick in order to have multi-line strings.

<script dangerouslySetInnerHTML={{__html: `
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('send', 'pageview');
`}} />

We should probably make it easier, it's quite a pain to use right now.

vjeux commented 10 years ago

See https://github.com/facebook/react/issues/654