Skip to content

Instantly share code, notes, and snippets.

@arvitaly
Created November 27, 2016 04:28
Show Gist options
  • Save arvitaly/1a93e0fb5e6be14d58acf5f96be1a304 to your computer and use it in GitHub Desktop.
Save arvitaly/1a93e0fb5e6be14d58acf5f96be1a304 to your computer and use it in GitHub Desktop.
React own element
import jsdom = require("jsdom");
import React = require("react");
import ReactElementSymbol = require("react/lib/ReactElementSymbol");
import ReactDOM = require("react-dom");
const window = jsdom.jsdom(`<div id="root"></div>`).defaultView;
global['window'] = window;
global['document'] = window.document;
class A extends React.Component<any, any>{
render() {
return { propTypes: { test: React.PropTypes.any }, '$$typeof': ReactElementSymbol, type: "ggg-x", key: "aaa", props: { test: "xxx" } }
}
}
//console.log(React.isValidElement( { '$$typeof': ReactElementSymbol, type: "ggg", key: "aaa", props: {} }))
ReactDOM.render(<A />, document.getElementById("root"));
console.log(document.getElementById("root").innerHTML);
//console.log(<A />)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment