YOO629
YOO629

Reputation: 89

React component with dangerouslySetInnerHTML, contain CSS

I have a React component that renders this element:

<div dangerouslySetInnerHTML={{__html: this.props.htmlString}}/>

It works fine, and the html is being rendered. However, the issue that I'm having is that my client code has CSS in place, which is reaching into the component that I'm rendering from this.props.htmlString. Is there a way to prevent my client CSS code from being applied to this component?

Upvotes: 1

Views: 2347

Answers (1)

Arnav Aggarwal
Arnav Aggarwal

Reputation: 789

You'd have to target the element in your CSS and override the styles that you don't want to be applied.

Upvotes: 2

Related Questions