Skip to content

Instantly share code, notes, and snippets.

@dallonf
Created October 6, 2015 21:11
Show Gist options
  • Save dallonf/42feeaa789109d5904d5 to your computer and use it in GitHub Desktop.
Save dallonf/42feeaa789109d5904d5 to your computer and use it in GitHub Desktop.
React can't render SVG under PhantomJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<svg id="svgRoot">
<g id="gElement">
</g>
</svg>
<script src="https://fb.me/react-0.14.0-rc1.js"></script>
<script src="https://fb.me/react-dom-0.14.0-rc1.js"></script>
<script type="text/javascript">
var circle = React.createElement("circle", {
r: 50,
fill: "red",
cx: 50,
cy: 50,
});
ReactDOM.render(circle, document.getElementById("gElement"));
</script>
</body>
</html>
var page = require('webpage').create();
page.open('http://localhost:3000', function(status) {
console.log("Status: " + status);
if(status === "success") {
page.render('example.png');
}
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment