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>`
}}></div>
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.
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #Json
- #Class
- #SASS
- #Form
- #Redirect
- #API
- #Special Characters
- #Special
- #Random
- #Generating
- #
- #Text
- #Ajax
- #URL
- #Encrypting
- #React
- #Show
- #timeAgo
- #PSR-4
- #Hide
- #DDOS Protection
- #DDOS
- #cURL
- #Logic For Displaying Posts
- #Error
- #Key
- #General Error
- #1364 Field
- #Abbreviation
- #Blade
- #Version
- #QR
- #QR Code Generating
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Activate
- #Real Time
- #Socket.io
- #301
- #Custom Directives
- #Iframe Detection
- #Date
- #Characters
- #Insert
- #Autoloader
- #Composer
- #Reading
There are no comments, make the firs comment