1

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?

1
  • This sounds like a typical issue with global CSS. If you use styled CSS or CSS Modules it might solve your issue. Commented May 26, 2017 at 17:31

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Sigh...That's what I thought. Fortunately, there are only like 3-4 properties that I need to stop from being inherited but I sure wish there was a way to just stop inheritance from a parent container and use default values instead. Maybe a good idea for a side project later on..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.