Better support for <script>
See original GitHub issue<script>
is a bit hard to use right now.
- If you have a
{...}
then it’s going to start interpolating. And you are bound to have whenever you useif
,function
… Workaround: you can wrap it inside of an interpolated string{'if (true) { ... }'}
- If you have any
'
or"
it’s going to output the html encoded version and Javascript is going to throw a parsing exception.
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.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top Results From Across the Web
How to Write a Great Customer Support Script for Frontline ...
Drafting a new customer support script, but don't know where to begin? Follow these sure-fire tips to set up your agents for success....
Read more >Customer Service Call Scripts for IT Help Desks: 7 Best ...
One way to improve your IT help desk performance is to use customer service call scripts. Here are some examples and best practices...
Read more >Run a support script - ExtraHop Documentation
In the Status and Diagnostics section, click Support Scripts. · Click Run Custom Support Script. · Click Choose File, navigate to the diagnostic...
Read more >50+ Customer Service Scripts For Your Team
Explore 50+ ready-to-use customer service script templates. ... Read More: Choose the Best Customer Support Channels for Your Growing ...
Read more >Use These Scripts To Get More Effective Support, Ideas, And ...
Below, you'll find 8 dos and don'ts of asking for support for your small business. Plus, I've provided a number of scripts you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@spicyj If I may answer for @matthewwithanm, since I just ran into the same issue, we still have some server-side rendered pages that we would like to open inside a modal dialog.
I made a Dialog component that gets a URL via props, and on componentDidMount fetches HTML from the server, and renders it inside the dialog using dangerouslySetInnerHTML. I was quite surprised when I found out that the code inside the
script
tag that was also in the fetched HTML was not executed.@syranide thanks for sharing that! i didn’t know it before