question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with `dangerouslySetInnerHTML`?

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
SiqiTian-mintedcommented, Mar 20, 2017

@bringking Hi, thanks a lot for testing! I tested with your example too, and it works. I found that the problem is with preact, not react. As the dangerouslySetInnerHTML content disappears when I have this in webpack.config.js:

    resolve: {
        alias: {
            react: 'preact-compat',
            'react-dom': 'preact-compat',
        },
    },

I use preact because of its smaller size. I will create another ticket there. Thanks!

0reactions
bringkingcommented, Mar 20, 2017

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found