-
Notifications
You must be signed in to change notification settings - Fork 47.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ServerRendering): execution should be async #982
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,30 +27,27 @@ var invariant = require('invariant'); | |
|
||
/** | ||
* @param {ReactComponent} component | ||
* @param {function} callback | ||
* @return {String} the markup | ||
*/ | ||
function renderComponentToString(component, callback) { | ||
// We use a callback API to keep the API async in case in the future we ever | ||
// need it, but in reality this is a synchronous operation. | ||
|
||
function renderComponentToString(component) { | ||
invariant( | ||
ReactComponent.isValidComponent(component), | ||
'renderComponentToString(): You must pass a valid ReactComponent.' | ||
); | ||
|
||
invariant( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that this should be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am cool with this |
||
typeof callback === 'function', | ||
'renderComponentToString(): You must pass a function as a callback.' | ||
!(arguments.length === 2 && typeof arguments[1] === 'function'), | ||
'renderComponentToString(): This function became synchronous and now ' + | ||
'returns the generated markup. Please remove the second parameter.' | ||
); | ||
|
||
var id = ReactInstanceHandles.createReactRootID(); | ||
var transaction = ReactReconcileTransaction.getPooled(); | ||
transaction.reinitializeTransaction(); | ||
try { | ||
transaction.perform(function() { | ||
return transaction.perform(function() { | ||
var markup = component.mountComponent(id, transaction, 0); | ||
markup = ReactMarkupChecksum.addChecksumToMarkup(markup); | ||
callback(markup); | ||
return ReactMarkupChecksum.addChecksumToMarkup(markup); | ||
}, null); | ||
} finally { | ||
ReactReconcileTransaction.release(transaction); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fails our internal typechecker. making it lowercase makes it succeed. can you make this change?