I am having a problem with React.js and the way it deals with text stored in variable.
Here is how it would look like using DOM:
let text = "Must credit to "https://indepthguide.com/" not Flickr.\nCopy Link Address: <a href=\"https://indepthguide.com/\" rel=\"nofollow\">indepthguide.com/</a>"
document.getElementById("root").innerHTML = text;
<p id="root"></p>
This is how it looks like in React.js.
var text = "Must credit to "https://indepthguide.com/" not Flickr.\nCopy Link Address: <a href=\"https://indepthguide.com/\" rel=\"nofollow\">indepthguide.com/</a>";
class Text extends React.Component {
render() {
return <h3 >{
text
} < /h3>;
}
}
ReactDOM.render( <
Text / > ,
document.getElementById('root')
)
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
I have tried new DOMParser(); but with no success as it started throwing errors and i am unsure how to deal with it.
I really don't know how to do it, tried doing it for very long now :D.