mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
React.renderComponent -> React.render
Also rename all the associated render methods and adds deprecation notices.
This commit is contained in:
1 parent
436c6c2db7
commit
9b1fa914fa
4 files changed
+109
-21
No files matched your search
+38
-11
@@ -43,6 +43,7 @@ var ReactPropTypes = require('ReactPropTypes');
|
||||
var ReactServerRendering = require('ReactServerRendering');
|
||||
var ReactTextComponent = require('ReactTextComponent');
|
||||
|
||||
var deprecated = require('deprecated');
|
||||
var onlyChild = require('onlyChild');
|
||||
|
||||
ReactDefaultInjection.inject();
|
||||
@@ -63,6 +64,8 @@ createFactory = ReactLegacyElement.wrapCreateFactory(
|
||||
createFactory
|
||||
);
|
||||
|
||||
var render = ReactPerf.measure('React', 'render', ReactMount.render);
|
||||
|
||||
var React = {
|
||||
Children: {
|
||||
map: ReactChildren.map,
|
||||
@@ -76,22 +79,16 @@ var React = {
|
||||
EventPluginUtils.useTouchEvents = shouldUseTouch;
|
||||
},
|
||||
createClass: ReactCompositeComponent.createClass,
|
||||
createDescriptor: createElement, // deprecated, will be removed next week
|
||||
createElement: createElement,
|
||||
createFactory: createFactory,
|
||||
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
|
||||
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
|
||||
renderComponent: ReactPerf.measure(
|
||||
'React',
|
||||
'renderComponent',
|
||||
ReactMount.renderComponent
|
||||
),
|
||||
renderComponentToString: ReactServerRendering.renderComponentToString,
|
||||
renderComponentToStaticMarkup:
|
||||
ReactServerRendering.renderComponentToStaticMarkup,
|
||||
render: render,
|
||||
renderToString: ReactServerRendering.renderToString,
|
||||
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
|
||||
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
|
||||
isValidClass: ReactLegacyElement.isValidFactory,
|
||||
isValidComponent: ReactElement.isValidElement,
|
||||
isValidElement: ReactElement.isValidElement,
|
||||
withContext: ReactContext.withContext,
|
||||
__internals: {
|
||||
Component: ReactComponent,
|
||||
@@ -102,7 +99,37 @@ var React = {
|
||||
Mount: ReactMount,
|
||||
MultiChild: ReactMultiChild,
|
||||
TextComponent: ReactTextComponent
|
||||
}
|
||||
},
|
||||
|
||||
// Deprecations (remove for 0.13)
|
||||
renderComponent: deprecated(
|
||||
'React',
|
||||
'renderComponent',
|
||||
'render',
|
||||
this,
|
||||
render
|
||||
),
|
||||
renderComponentToString: deprecated(
|
||||
'React',
|
||||
'renderComponentToString',
|
||||
'renderToString',
|
||||
this,
|
||||
ReactServerRendering.renderToString
|
||||
),
|
||||
renderComponentToStaticMarkup: deprecated(
|
||||
'React',
|
||||
'renderComponentToStaticMarkup',
|
||||
'renderToStaticMarkup',
|
||||
this,
|
||||
ReactServerRendering.renderToStaticMarkup
|
||||
),
|
||||
isValidComponent: deprecated(
|
||||
'React',
|
||||
'isValidComponent',
|
||||
'isValidElement',
|
||||
this,
|
||||
ReactElement.isValidElement
|
||||
)
|
||||
};
|
||||
|
||||
if (__DEV__) {
|
||||
|
||||
@@ -27,6 +27,7 @@ var ReactInstanceHandles = require('ReactInstanceHandles');
|
||||
var ReactPerf = require('ReactPerf');
|
||||
|
||||
var containsNode = require('containsNode');
|
||||
var deprecated = require('deprecated');
|
||||
var getReactRootElementInContainer = require('getReactRootElementInContainer');
|
||||
var instantiateReactComponent = require('instantiateReactComponent');
|
||||
var invariant = require('invariant');
|
||||
@@ -204,7 +205,7 @@ function findDeepestCachedAncestor(targetID) {
|
||||
* representative DOM elements and inserting them into a supplied `container`.
|
||||
* Any prior content inside `container` is destroyed in the process.
|
||||
*
|
||||
* ReactMount.renderComponent(
|
||||
* ReactMount.render(
|
||||
* component,
|
||||
* document.getElementById('container')
|
||||
* );
|
||||
@@ -340,7 +341,7 @@ var ReactMount = {
|
||||
* @param {?function} callback function triggered on completion
|
||||
* @return {ReactComponent} Component instance rendered in `container`.
|
||||
*/
|
||||
renderComponent: function(nextElement, container, callback) {
|
||||
render: function(nextElement, container, callback) {
|
||||
invariant(
|
||||
ReactElement.isValidElement(nextElement),
|
||||
'renderComponent(): Invalid component element.%s',
|
||||
@@ -401,7 +402,7 @@ var ReactMount = {
|
||||
*/
|
||||
constructAndRenderComponent: function(constructor, props, container) {
|
||||
var element = createElement(constructor, props);
|
||||
return ReactMount.renderComponent(element, container);
|
||||
return ReactMount.render(element, container);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -683,4 +684,13 @@ var ReactMount = {
|
||||
purgeID: purgeID
|
||||
};
|
||||
|
||||
// Deprecations (remove for 0.13)
|
||||
ReactMount.renderComponent = deprecated(
|
||||
'ReactMount',
|
||||
'renderComponent',
|
||||
'render',
|
||||
this,
|
||||
ReactMount.render
|
||||
);
|
||||
|
||||
module.exports = ReactMount;
|
||||
Reference in new issue
Block a user