A
A
Andrey Okhotnikov2020-12-30 14:17:11
css
Andrey Okhotnikov, 2020-12-30 14:17:11

Overriding styles in dangerouslySetInnerHTML?

There is a component in React that receives markup from the server in the form of HTML - it is filled in through the editor in the admin panel, it looks like this
5fec613eb2fd3314510000.png

But when I insert html

<Section
      dangerouslySetInnerHTML={{
        __html: description
      }}
    />


Styles received from the server are overridden by site styles, because of this it is displayed incorrectly
5fec619f623f0761596071.png

How to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Nanavov, 2020-12-30
@fertyga098

Alternatively, use styles.module.(css|sass|scss), then each class will be unique and inimitable, and styles will not override your styles, BUT there is a minus you will have to rewrite all files to .module.css

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question