Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
renderToObject
function renderToObject(element) {
const inst = instantiateReactComponent(element);
inst.state = inst.getInitialState ? inst.getInitialState() : null;
return Promise.resolve(inst.componentWillMount ? inst.componentWillMount() : null)
.then(() => {
const r = inst.render();
inst.componentWillUnmount();
return r;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment