mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
react app
This commit is contained in:
78
react-app/node_modules/react/lib/ReactServerRendering.js
generated
vendored
Normal file
78
react-app/node_modules/react/lib/ReactServerRendering.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @typechecks static-only
|
||||
* @providesModule ReactServerRendering
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactElement = require("./ReactElement");
|
||||
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
||||
var ReactMarkupChecksum = require("./ReactMarkupChecksum");
|
||||
var ReactServerRenderingTransaction =
|
||||
require("./ReactServerRenderingTransaction");
|
||||
|
||||
var emptyObject = require("./emptyObject");
|
||||
var instantiateReactComponent = require("./instantiateReactComponent");
|
||||
var invariant = require("./invariant");
|
||||
|
||||
/**
|
||||
* @param {ReactElement} element
|
||||
* @return {string} the HTML markup
|
||||
*/
|
||||
function renderToString(element) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
ReactElement.isValidElement(element),
|
||||
'renderToString(): You must pass a valid ReactElement.'
|
||||
) : invariant(ReactElement.isValidElement(element)));
|
||||
|
||||
var transaction;
|
||||
try {
|
||||
var id = ReactInstanceHandles.createReactRootID();
|
||||
transaction = ReactServerRenderingTransaction.getPooled(false);
|
||||
|
||||
return transaction.perform(function() {
|
||||
var componentInstance = instantiateReactComponent(element, null);
|
||||
var markup =
|
||||
componentInstance.mountComponent(id, transaction, emptyObject);
|
||||
return ReactMarkupChecksum.addChecksumToMarkup(markup);
|
||||
}, null);
|
||||
} finally {
|
||||
ReactServerRenderingTransaction.release(transaction);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ReactElement} element
|
||||
* @return {string} the HTML markup, without the extra React ID and checksum
|
||||
* (for generating static pages)
|
||||
*/
|
||||
function renderToStaticMarkup(element) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
ReactElement.isValidElement(element),
|
||||
'renderToStaticMarkup(): You must pass a valid ReactElement.'
|
||||
) : invariant(ReactElement.isValidElement(element)));
|
||||
|
||||
var transaction;
|
||||
try {
|
||||
var id = ReactInstanceHandles.createReactRootID();
|
||||
transaction = ReactServerRenderingTransaction.getPooled(true);
|
||||
|
||||
return transaction.perform(function() {
|
||||
var componentInstance = instantiateReactComponent(element, null);
|
||||
return componentInstance.mountComponent(id, transaction, emptyObject);
|
||||
}, null);
|
||||
} finally {
|
||||
ReactServerRenderingTransaction.release(transaction);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
renderToString: renderToString,
|
||||
renderToStaticMarkup: renderToStaticMarkup
|
||||
};
|
Reference in New Issue
Block a user