How to use innerHTML in React.js ?

Answer

The SetInnerHTML attribute is React's replacement for using innerHTML in the browser DOM.
Just like innerHTML, it is risky to use this attribute considering cross-site scripting (XSS) attacks.
You just need to pass a __html object as key and HTML text as value.

Example:
function createMarkup() {
return { __html: 'First · Second' }
}

function MyComponent() {
return <div dangerouslySetInnerHTML={createMarkup()} />
}

All react js Questions

Ask your interview questions on react-js

Write Your comment or Questions if you want the answers on react-js from react-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---