Skip to content

Instantly share code, notes, and snippets.

@elierotenberg
Created January 4, 2015 23:31
Show Gist options
  • Save elierotenberg/6da11c21ce0a1c5420d8 to your computer and use it in GitHub Desktop.
Save elierotenberg/6da11c21ce0a1c5420d8 to your computer and use it in GitHub Desktop.
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