-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Better support for <script> #654
Comments
What should it even mean to include a |
Yeah, i'm not really sure that it is really useful in a normal React app but for react-page it's definitively useful. @zpao suggested that we change the |
I could look into fixing this... from what I understand, what needs to be done is to create a What should happen if the string changes? Simply update the Seems about right? |
@spicyj It stills seems like being able to render into |
Just ran into this. IMO, it's very surprising behavior that adding a |
@matthewwithanm Can you say a little more about your use case? I think we'd like to do the least surprising thing here but it's hard to know what that is; my guess is any behavior we have would be surprising in some way. |
@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 |
@marten |
@syranide I guess I was just spoiled by jQuery and never realized that. I've already implemented this same behaviour myself, and it's for a layer that should be converted to actual React components anyway, so the workaround should disappear from our code at some point. It's not a big deal, just surprised me, but I guess it's just a lack of knowledge on my part. |
@syranide thanks for sharing that! i didn't know it before |
<script>
is a bit hard to use right now.{...}
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) { ... }'}
'
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.
We should probably make it easier, it's quite a pain to use right now.
The text was updated successfully, but these errors were encountered: