Using HTML in React

If you are new to React and you know that the code you have written is jsx, not html, and you suddenly needed to render raw html code in line with a need, if you searched google for it in Turkish and somehow your seo was good and you came across this topic, you are in the right place.

But if you are a stackoverflow developer (call and get the relevant code and never read what is written), you probably won't see it here either, but okay :D

Simply react asks us to pass a prop with the name dangerouslySetInnerHTML and define a nail polish in it and define the html to render with the __html key.

<div dangerouslySetInnerHTML={{
    __html: `<i>this is test</i>`

Of course, remember that you can also print the html value from a variable instead of code.

The reason why the name is so scary is that you should think twice while doing it :) You know, xss is likely to occur and it may be dangerous for your project, but if you say that I handled everything well, you are free to use it.


There are no comments, make the firs comment