Search code examples
reactjsnext.jsdangerouslysetinnerhtml

React reference for third party html tag


I'm looking for a way to add appearing animations with useInView hook. The problem is that I don't have the tag that I need in my code, I get it from third party Ghost as one single tag via dangerouslySetInnerHTML.

dangerouslySetInnerHTML={{__html: props.post.html}}/>

Is there any way to do it in React way?


Solution

  • You can just use web-components in JSX directly, as described in the react documentation. JSX transform should take care of it.

    If you don't know the tag before compile-time there's no other way than using dangerouslySetInnerHTML.