I am embedding HTML inside SVG via foreignobject
:
var SvgWithForeignObject = React.createClass({
render: function() {
return(
<svg>
<foreignobject><div>Hello From SVG</div></foreignobject>
</svg>
)
}
});
ReactDOM.render( < SvgWithForeignObject / > ,
document.getElementById('container')
);
<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="container">
<!-- This element's contents will be replaced with your component. -->
</div>
The "Hello From SVG" string is not rendered. However, I can make a minor whitespace edit in Chrome or FF and then it becomes visible:
(Note: The screen recording is from an example where I use React via Scala.js, but the behavior is exactly the same with plain React)