Problem with `dangerouslySetInnerHTML`?
See original GitHub issueHi, I was glad being able to use react-web-animations
, cool library!
I found something strange when I have an element with dangerouslySetInnerHTML
inside <Animation/>
. Simply, the dangerouslySetInnerHTML
content is not displayed before onPlay
. Once trigged play, it would be fine.
Also tried all possible fill
options, got the same behavior.
If I use <Animation/>
inside a wrapper component, and force shouldComponentUpdate
of the wrapper, I see that both before and after animation the dangerouslySetInnerHTML
is lost, while only during the animation they are displayed.
Any ideas? Could this be a react
thing?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Safe alternative to dangerouslySetInnerHTML - Stack Overflow
Alternative 1: Rewrite your app to pass data to components instead · Alternative 2: Don't write your own page builder · Alternative 3...
Read more >What Is DangerouslySetInnerHTML? - Better Programming
dangerouslySetInnerHTML is an attribute under DOM elements in React. According to the official documentation, dangerouslySetInnerHTML is React's ...
Read more >Preventing XSS in React (Part 2): dangerouslySetInnerHTML
Dynamically rendering benign HTML code in React requires the use of dangerouslySetInnerHTML . That is not a naming mistake. This property is ...
Read more >Using dangerouslySetInnerHTML in a React application
As the name of the property suggests, it can be dangerous to use because it makes your code vulnerable to cross-site scripting (XSS)...
Read more >DangerouslySetInnerHTML in React JS Explained
dangerouslySetInnerHTML is an attribute under DOM elements in React. According to the official documentation, dangerouslySetInnerHTML is React's replacement ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
@bringking Hi, thanks a lot for testing! I tested with your example too, and it works. I found that the problem is with
preact
, notreact
. As thedangerouslySetInnerHTML
content disappears when I have this inwebpack.config.js
:I use
preact
because of its smaller size. I will create another ticket there. Thanks!@SiqiTian-minted I don’t know yet, haven’t dug in, I think it might be related to the way we rely on
refs
to get access to the node… but that is just a hunch