Skip to content

Instantly share code, notes, and snippets.

@tgriesser
Created June 27, 2014 20:31
Show Gist options
  • Save tgriesser/db8330e04f27ae5ac077 to your computer and use it in GitHub Desktop.
Save tgriesser/db8330e04f27ae5ac077 to your computer and use it in GitHub Desktop.
renderComponentToInstance
// Added In ReactServerRendering.js
function renderComponentToInstance(component) {
var transaction;
try {
var id = ReactInstanceHandles.createReactRootID();
transaction = ReactServerRenderingTransaction.getPooled(false);
return transaction.perform(function() {
var componentInstance = instantiateReactComponent(component);
componentInstance.mountComponent(id, transaction, 0);
return componentInstance._renderedComponent;
}, null);
} finally {
ReactServerRenderingTransaction.release(transaction);
}
}
module.exports = {
renderComponentToInstance: renderComponentToInstance,
renderComponentToString: renderComponentToString,
renderComponentToStaticMarkup: renderComponentToStaticMarkup
};
// Then:
var component = React.renderComponentToInstance(Component({props: arg}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment