snippetjavascriptreactMajor
How do I render raw HTML with React?
Viewed 0 times
htmlrenderrawreactwithhow
Problem
So is this the only way to render raw html with reactjs?
I know there are some cool ways to markup stuff with JSX, but I am mainly interested in being able to render raw html (with all the classes, inline styles, etc..). Something complicated like this:
I would not want to have to rewrite all of that in JSX.
Maybe I am thinking about this all wrong. Please correct me.
// http://facebook.github.io/react/docs/tutorial.html
// tutorial7.js
var converter = new Showdown.converter();
var Comment = React.createClass({
render: function() {
var rawMarkup = converter.makeHtml(this.props.children.toString());
return (
{this.props.author}
);
}
});I know there are some cool ways to markup stuff with JSX, but I am mainly interested in being able to render raw html (with all the classes, inline styles, etc..). Something complicated like this:
Dropdown
Action
Another action
Something else here
Separated link
I would not want to have to rewrite all of that in JSX.
Maybe I am thinking about this all wrong. Please correct me.
Solution
You could leverage the
Note: I'm the author of the module and just published it a few hours ago. Please feel free to report any bugs or usability issues.
html-to-react npm module.Note: I'm the author of the module and just published it a few hours ago. Please feel free to report any bugs or usability issues.
Context
Stack Overflow Q#27934238, score: 81
Revisions (0)
No revisions yet.