CSS not working on dangerouslySetInnerHTML React
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
I receive HTML from a API call wich I display like this :
{props.content && <div>
{textToDisplay && <div dangerouslySetInnerHTML={{ __html: textToDisplay }} className=”my-4″>
</div>}}
I created a style.css to style all types of tags I can receive. Example :
h1 {
font-family: “Montserrat”, sans-serif;
font-weight: 800;
font-size: 2rem;
line-height: 1.2;
}
h2 {
font-family: “Montserrat”, sans-serif;
font-weight: 800;
font-size: 1.8rem;
line-height: 1.2;
}
[…]
But the problem is, the CSS is not working. It only work if I remove the import of the CSS file and set it again. But on refresh, my custom css disappear.
Do you have a idea how I can make this to work ?
Thank you for your help 🙂
أضف إجابة