react 0.14.10 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +102 -21
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +7 -4
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +12 -13
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
package/lib/ReactComponent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
15
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
15
16
|
|
|
16
17
|
var canDefineProperty = require('./canDefineProperty');
|
|
17
18
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
@@ -58,13 +59,14 @@ ReactComponent.prototype.isReactComponent = {};
|
|
|
58
59
|
* @protected
|
|
59
60
|
*/
|
|
60
61
|
ReactComponent.prototype.setState = function (partialState, callback) {
|
|
61
|
-
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) :
|
|
62
|
+
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) : void 0;
|
|
62
63
|
if (process.env.NODE_ENV !== 'production') {
|
|
63
|
-
|
|
64
|
+
ReactInstrumentation.debugTool.onSetState();
|
|
65
|
+
process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : void 0;
|
|
64
66
|
}
|
|
65
67
|
this.updater.enqueueSetState(this, partialState);
|
|
66
68
|
if (callback) {
|
|
67
|
-
this.updater.enqueueCallback(this, callback);
|
|
69
|
+
this.updater.enqueueCallback(this, callback, 'setState');
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
|
|
@@ -85,7 +87,7 @@ ReactComponent.prototype.setState = function (partialState, callback) {
|
|
|
85
87
|
ReactComponent.prototype.forceUpdate = function (callback) {
|
|
86
88
|
this.updater.enqueueForceUpdate(this);
|
|
87
89
|
if (callback) {
|
|
88
|
-
this.updater.enqueueCallback(this, callback);
|
|
90
|
+
this.updater.enqueueCallback(this, callback, 'forceUpdate');
|
|
89
91
|
}
|
|
90
92
|
};
|
|
91
93
|
|
|
@@ -96,17 +98,14 @@ ReactComponent.prototype.forceUpdate = function (callback) {
|
|
|
96
98
|
*/
|
|
97
99
|
if (process.env.NODE_ENV !== 'production') {
|
|
98
100
|
var deprecatedAPIs = {
|
|
99
|
-
getDOMNode: ['getDOMNode', 'Use ReactDOM.findDOMNode(component) instead.'],
|
|
100
101
|
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
101
|
-
|
|
102
|
-
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'],
|
|
103
|
-
setProps: ['setProps', 'Instead, call render again at the top level.']
|
|
102
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
104
103
|
};
|
|
105
104
|
var defineDeprecationWarning = function (methodName, info) {
|
|
106
105
|
if (canDefineProperty) {
|
|
107
106
|
Object.defineProperty(ReactComponent.prototype, methodName, {
|
|
108
107
|
get: function () {
|
|
109
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) :
|
|
108
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : void 0;
|
|
110
109
|
return undefined;
|
|
111
110
|
}
|
|
112
111
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
14
15
|
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
15
|
-
var
|
|
16
|
+
var ReactPerf = require('./ReactPerf');
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Abstracts away all functionality of the reconciler that requires knowledge of
|
|
@@ -23,7 +24,7 @@ var ReactComponentBrowserEnvironment = {
|
|
|
23
24
|
|
|
24
25
|
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup,
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* If a particular environment requires that some resources be cleaned up,
|
|
@@ -32,10 +33,12 @@ var ReactComponentBrowserEnvironment = {
|
|
|
32
33
|
*
|
|
33
34
|
* @private
|
|
34
35
|
*/
|
|
35
|
-
unmountIDFromEnvironment: function (rootNodeID) {
|
|
36
|
-
ReactMount.purgeID(rootNodeID);
|
|
37
|
-
}
|
|
36
|
+
unmountIDFromEnvironment: function (rootNodeID) {}
|
|
38
37
|
|
|
39
38
|
};
|
|
40
39
|
|
|
40
|
+
ReactPerf.measureMethods(ReactComponentBrowserEnvironment, 'ReactComponentBrowserEnvironment', {
|
|
41
|
+
replaceNodeWithMarkup: 'replaceNodeWithMarkup'
|
|
42
|
+
});
|
|
43
|
+
|
|
41
44
|
module.exports = ReactComponentBrowserEnvironment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -28,7 +28,7 @@ var ReactComponentEnvironment = {
|
|
|
28
28
|
* Optionally injectable hook for swapping out mount images in the middle of
|
|
29
29
|
* the tree.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
replaceNodeWithMarkup: null,
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Optionally injectable hook for processing a queue of child updates. Will
|
|
@@ -38,9 +38,9 @@ var ReactComponentEnvironment = {
|
|
|
38
38
|
|
|
39
39
|
injection: {
|
|
40
40
|
injectEnvironment: function (environment) {
|
|
41
|
-
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) :
|
|
41
|
+
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : void 0;
|
|
42
42
|
ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
|
|
43
|
-
ReactComponentEnvironment.
|
|
43
|
+
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
|
|
44
44
|
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
|
|
45
45
|
injected = true;
|
|
46
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -15,7 +15,7 @@ var shallowCompare = require('./shallowCompare');
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* If your React component's render function is "pure", e.g. it will render the
|
|
18
|
-
* same result given the same props and state, provide this
|
|
18
|
+
* same result given the same props and state, provide this mixin for a
|
|
19
19
|
* considerable performance boost.
|
|
20
20
|
*
|
|
21
21
|
* Most React components have pure render functions.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,17 +11,21 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
|
|
15
17
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
16
18
|
var ReactElement = require('./ReactElement');
|
|
19
|
+
var ReactErrorUtils = require('./ReactErrorUtils');
|
|
17
20
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
21
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
22
|
+
var ReactNodeTypes = require('./ReactNodeTypes');
|
|
18
23
|
var ReactPerf = require('./ReactPerf');
|
|
19
24
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
20
25
|
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
21
26
|
var ReactReconciler = require('./ReactReconciler');
|
|
22
27
|
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
23
28
|
|
|
24
|
-
var assign = require('./Object.assign');
|
|
25
29
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
26
30
|
var invariant = require('fbjs/lib/invariant');
|
|
27
31
|
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
@@ -41,9 +45,17 @@ function getDeclarationErrorAddendum(component) {
|
|
|
41
45
|
function StatelessComponent(Component) {}
|
|
42
46
|
StatelessComponent.prototype.render = function () {
|
|
43
47
|
var Component = ReactInstanceMap.get(this)._currentElement.type;
|
|
44
|
-
|
|
48
|
+
var element = Component(this.props, this.context, this.updater);
|
|
49
|
+
warnIfInvalidElement(Component, element);
|
|
50
|
+
return element;
|
|
45
51
|
};
|
|
46
52
|
|
|
53
|
+
function warnIfInvalidElement(Component, element) {
|
|
54
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
55
|
+
process.env.NODE_ENV !== 'production' ? warning(element === null || element === false || ReactElement.isValidElement(element), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : void 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
/**
|
|
48
60
|
* ------------------ The Life-Cycle of a Composite Component ------------------
|
|
49
61
|
*
|
|
@@ -95,6 +107,8 @@ var ReactCompositeComponentMixin = {
|
|
|
95
107
|
this._currentElement = element;
|
|
96
108
|
this._rootNodeID = null;
|
|
97
109
|
this._instance = null;
|
|
110
|
+
this._nativeParent = null;
|
|
111
|
+
this._nativeContainerInfo = null;
|
|
98
112
|
|
|
99
113
|
// See ReactUpdateQueue
|
|
100
114
|
this._pendingElement = null;
|
|
@@ -102,8 +116,8 @@ var ReactCompositeComponentMixin = {
|
|
|
102
116
|
this._pendingReplaceState = false;
|
|
103
117
|
this._pendingForceUpdate = false;
|
|
104
118
|
|
|
119
|
+
this._renderedNodeType = null;
|
|
105
120
|
this._renderedComponent = null;
|
|
106
|
-
|
|
107
121
|
this._context = null;
|
|
108
122
|
this._mountOrder = 0;
|
|
109
123
|
this._topLevelWrapper = null;
|
|
@@ -115,16 +129,19 @@ var ReactCompositeComponentMixin = {
|
|
|
115
129
|
/**
|
|
116
130
|
* Initializes the component, renders markup, and registers event listeners.
|
|
117
131
|
*
|
|
118
|
-
* @param {string} rootID DOM ID of the root node.
|
|
119
132
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
133
|
+
* @param {?object} nativeParent
|
|
134
|
+
* @param {?object} nativeContainerInfo
|
|
135
|
+
* @param {?object} context
|
|
120
136
|
* @return {?string} Rendered markup to be inserted into the DOM.
|
|
121
137
|
* @final
|
|
122
138
|
* @internal
|
|
123
139
|
*/
|
|
124
|
-
mountComponent: function (
|
|
140
|
+
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
125
141
|
this._context = context;
|
|
126
142
|
this._mountOrder = nextMountID++;
|
|
127
|
-
this.
|
|
143
|
+
this._nativeParent = nativeParent;
|
|
144
|
+
this._nativeContainerInfo = nativeContainerInfo;
|
|
128
145
|
|
|
129
146
|
var publicProps = this._processProps(this._currentElement.props);
|
|
130
147
|
var publicContext = this._processContext(context);
|
|
@@ -135,13 +152,7 @@ var ReactCompositeComponentMixin = {
|
|
|
135
152
|
var inst;
|
|
136
153
|
var renderedElement;
|
|
137
154
|
|
|
138
|
-
|
|
139
|
-
// component, which is not newable. It might not be 100% reliable but is
|
|
140
|
-
// something we can do until we start detecting that Component extends
|
|
141
|
-
// React.Component. We already assume that typeof Component === 'function'.
|
|
142
|
-
var canInstantiate = ('prototype' in Component);
|
|
143
|
-
|
|
144
|
-
if (canInstantiate) {
|
|
155
|
+
if (Component.prototype && Component.prototype.isReactComponent) {
|
|
145
156
|
if (process.env.NODE_ENV !== 'production') {
|
|
146
157
|
ReactCurrentOwner.current = this;
|
|
147
158
|
try {
|
|
@@ -152,23 +163,36 @@ var ReactCompositeComponentMixin = {
|
|
|
152
163
|
} else {
|
|
153
164
|
inst = new Component(publicProps, publicContext, ReactUpdateQueue);
|
|
154
165
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
166
|
+
} else {
|
|
167
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
168
|
+
ReactCurrentOwner.current = this;
|
|
169
|
+
try {
|
|
170
|
+
inst = Component(publicProps, publicContext, ReactUpdateQueue);
|
|
171
|
+
} finally {
|
|
172
|
+
ReactCurrentOwner.current = null;
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
inst = Component(publicProps, publicContext, ReactUpdateQueue);
|
|
176
|
+
}
|
|
177
|
+
if (inst == null || inst.render == null) {
|
|
178
|
+
renderedElement = inst;
|
|
179
|
+
warnIfInvalidElement(Component, renderedElement);
|
|
180
|
+
!(inst === null || inst === false || ReactElement.isValidElement(inst)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : invariant(false) : void 0;
|
|
181
|
+
inst = new StatelessComponent(Component);
|
|
182
|
+
}
|
|
160
183
|
}
|
|
161
184
|
|
|
162
185
|
if (process.env.NODE_ENV !== 'production') {
|
|
163
186
|
// This will throw later in _renderValidatedComponent, but add an early
|
|
164
187
|
// warning now to help debugging
|
|
165
188
|
if (inst.render == null) {
|
|
166
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render
|
|
167
|
-
} else {
|
|
168
|
-
// We support ES6 inheriting from React.Component, the module pattern,
|
|
169
|
-
// and stateless components, but not ES6 classes that don't extend
|
|
170
|
-
process.env.NODE_ENV !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined;
|
|
189
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', Component.displayName || Component.name || 'Component') : void 0;
|
|
171
190
|
}
|
|
191
|
+
|
|
192
|
+
var propsMutated = inst.props !== publicProps;
|
|
193
|
+
var componentName = Component.displayName || Component.name || 'Component';
|
|
194
|
+
|
|
195
|
+
process.env.NODE_ENV !== 'production' ? warning(inst.props === undefined || !propsMutated, '%s(...): When calling super() in `%s`, make sure to pass ' + 'up the same props that your component\'s constructor was passed.', componentName, componentName) : void 0;
|
|
172
196
|
}
|
|
173
197
|
|
|
174
198
|
// These should be set up in the constructor, but as a convenience for
|
|
@@ -187,25 +211,65 @@ var ReactCompositeComponentMixin = {
|
|
|
187
211
|
// Since plain JS classes are defined without any special initialization
|
|
188
212
|
// logic, we can not catch common errors early. Therefore, we have to
|
|
189
213
|
// catch them here, at initialization time, instead.
|
|
190
|
-
process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') :
|
|
191
|
-
process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') :
|
|
192
|
-
process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') :
|
|
193
|
-
process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') :
|
|
194
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', this.getName() || 'A component') :
|
|
195
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') :
|
|
196
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') :
|
|
214
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : void 0;
|
|
215
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : void 0;
|
|
216
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : void 0;
|
|
217
|
+
process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : void 0;
|
|
218
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', this.getName() || 'A component') : void 0;
|
|
219
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : void 0;
|
|
220
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : void 0;
|
|
197
221
|
}
|
|
198
222
|
|
|
199
223
|
var initialState = inst.state;
|
|
200
224
|
if (initialState === undefined) {
|
|
201
225
|
inst.state = initialState = null;
|
|
202
226
|
}
|
|
203
|
-
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) :
|
|
227
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : void 0;
|
|
204
228
|
|
|
205
229
|
this._pendingStateQueue = null;
|
|
206
230
|
this._pendingReplaceState = false;
|
|
207
231
|
this._pendingForceUpdate = false;
|
|
208
232
|
|
|
233
|
+
var markup;
|
|
234
|
+
if (inst.unstable_handleError) {
|
|
235
|
+
markup = this.performInitialMountWithErrorHandling(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
236
|
+
} else {
|
|
237
|
+
markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (inst.componentDidMount) {
|
|
241
|
+
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return markup;
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
performInitialMountWithErrorHandling: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
|
|
248
|
+
var markup;
|
|
249
|
+
var checkpoint = transaction.checkpoint();
|
|
250
|
+
try {
|
|
251
|
+
markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
252
|
+
} catch (e) {
|
|
253
|
+
// Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
|
|
254
|
+
transaction.rollback(checkpoint);
|
|
255
|
+
this._instance.unstable_handleError(e);
|
|
256
|
+
if (this._pendingStateQueue) {
|
|
257
|
+
this._instance.state = this._processPendingState(this._instance.props, this._instance.context);
|
|
258
|
+
}
|
|
259
|
+
checkpoint = transaction.checkpoint();
|
|
260
|
+
|
|
261
|
+
this._renderedComponent.unmountComponent(true);
|
|
262
|
+
transaction.rollback(checkpoint);
|
|
263
|
+
|
|
264
|
+
// Try again - we've informed the component about the error, so they can render an error message this time.
|
|
265
|
+
// If this throws again, the error will bubble up (and can be caught by a higher error boundary).
|
|
266
|
+
markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
|
|
267
|
+
}
|
|
268
|
+
return markup;
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
performInitialMount: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
|
|
272
|
+
var inst = this._instance;
|
|
209
273
|
if (inst.componentWillMount) {
|
|
210
274
|
inst.componentWillMount();
|
|
211
275
|
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
@@ -220,32 +284,45 @@ var ReactCompositeComponentMixin = {
|
|
|
220
284
|
renderedElement = this._renderValidatedComponent();
|
|
221
285
|
}
|
|
222
286
|
|
|
287
|
+
this._renderedNodeType = ReactNodeTypes.getType(renderedElement);
|
|
223
288
|
this._renderedComponent = this._instantiateReactComponent(renderedElement);
|
|
224
289
|
|
|
225
|
-
var markup = ReactReconciler.mountComponent(this._renderedComponent,
|
|
226
|
-
if (inst.componentDidMount) {
|
|
227
|
-
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
|
228
|
-
}
|
|
290
|
+
var markup = ReactReconciler.mountComponent(this._renderedComponent, transaction, nativeParent, nativeContainerInfo, this._processChildContext(context));
|
|
229
291
|
|
|
230
292
|
return markup;
|
|
231
293
|
},
|
|
232
294
|
|
|
295
|
+
getNativeNode: function () {
|
|
296
|
+
return ReactReconciler.getNativeNode(this._renderedComponent);
|
|
297
|
+
},
|
|
298
|
+
|
|
233
299
|
/**
|
|
234
300
|
* Releases any resources allocated by `mountComponent`.
|
|
235
301
|
*
|
|
236
302
|
* @final
|
|
237
303
|
* @internal
|
|
238
304
|
*/
|
|
239
|
-
unmountComponent: function () {
|
|
305
|
+
unmountComponent: function (safely) {
|
|
306
|
+
if (!this._renderedComponent) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
240
309
|
var inst = this._instance;
|
|
241
310
|
|
|
242
311
|
if (inst.componentWillUnmount) {
|
|
243
|
-
|
|
312
|
+
if (safely) {
|
|
313
|
+
var name = this.getName() + '.componentWillUnmount()';
|
|
314
|
+
ReactErrorUtils.invokeGuardedCallback(name, inst.componentWillUnmount.bind(inst));
|
|
315
|
+
} else {
|
|
316
|
+
inst.componentWillUnmount();
|
|
317
|
+
}
|
|
244
318
|
}
|
|
245
319
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
320
|
+
if (this._renderedComponent) {
|
|
321
|
+
ReactReconciler.unmountComponent(this._renderedComponent, safely);
|
|
322
|
+
this._renderedNodeType = null;
|
|
323
|
+
this._renderedComponent = null;
|
|
324
|
+
this._instance = null;
|
|
325
|
+
}
|
|
249
326
|
|
|
250
327
|
// Reset pending fields
|
|
251
328
|
// Even if this component is scheduled for another update in ReactUpdates,
|
|
@@ -283,13 +360,12 @@ var ReactCompositeComponentMixin = {
|
|
|
283
360
|
* @private
|
|
284
361
|
*/
|
|
285
362
|
_maskContext: function (context) {
|
|
286
|
-
var maskedContext = null;
|
|
287
363
|
var Component = this._currentElement.type;
|
|
288
364
|
var contextTypes = Component.contextTypes;
|
|
289
365
|
if (!contextTypes) {
|
|
290
366
|
return emptyObject;
|
|
291
367
|
}
|
|
292
|
-
maskedContext = {};
|
|
368
|
+
var maskedContext = {};
|
|
293
369
|
for (var contextName in contextTypes) {
|
|
294
370
|
maskedContext[contextName] = context[contextName];
|
|
295
371
|
}
|
|
@@ -323,16 +399,22 @@ var ReactCompositeComponentMixin = {
|
|
|
323
399
|
_processChildContext: function (currentContext) {
|
|
324
400
|
var Component = this._currentElement.type;
|
|
325
401
|
var inst = this._instance;
|
|
402
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
403
|
+
ReactInstrumentation.debugTool.onBeginProcessingChildContext();
|
|
404
|
+
}
|
|
326
405
|
var childContext = inst.getChildContext && inst.getChildContext();
|
|
406
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
407
|
+
ReactInstrumentation.debugTool.onEndProcessingChildContext();
|
|
408
|
+
}
|
|
327
409
|
if (childContext) {
|
|
328
|
-
!(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) :
|
|
410
|
+
!(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : void 0;
|
|
329
411
|
if (process.env.NODE_ENV !== 'production') {
|
|
330
412
|
this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
|
|
331
413
|
}
|
|
332
414
|
for (var name in childContext) {
|
|
333
|
-
!(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) :
|
|
415
|
+
!(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : void 0;
|
|
334
416
|
}
|
|
335
|
-
return
|
|
417
|
+
return _assign({}, currentContext, childContext);
|
|
336
418
|
}
|
|
337
419
|
return currentContext;
|
|
338
420
|
},
|
|
@@ -374,8 +456,8 @@ var ReactCompositeComponentMixin = {
|
|
|
374
456
|
try {
|
|
375
457
|
// This is intentionally an invariant that gets caught. It's the same
|
|
376
458
|
// behavior as without this statement except with a better message.
|
|
377
|
-
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) :
|
|
378
|
-
error = propTypes[propName](props, propName, componentName, location
|
|
459
|
+
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : void 0;
|
|
460
|
+
error = propTypes[propName](props, propName, componentName, location);
|
|
379
461
|
} catch (ex) {
|
|
380
462
|
error = ex;
|
|
381
463
|
}
|
|
@@ -387,9 +469,9 @@ var ReactCompositeComponentMixin = {
|
|
|
387
469
|
|
|
388
470
|
if (location === ReactPropTypeLocations.prop) {
|
|
389
471
|
// Preface gives us something to blacklist in warning module
|
|
390
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) :
|
|
472
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : void 0;
|
|
391
473
|
} else {
|
|
392
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) :
|
|
474
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : void 0;
|
|
393
475
|
}
|
|
394
476
|
}
|
|
395
477
|
}
|
|
@@ -414,7 +496,7 @@ var ReactCompositeComponentMixin = {
|
|
|
414
496
|
*/
|
|
415
497
|
performUpdateIfNecessary: function (transaction) {
|
|
416
498
|
if (this._pendingElement != null) {
|
|
417
|
-
ReactReconciler.receiveComponent(this, this._pendingElement
|
|
499
|
+
ReactReconciler.receiveComponent(this, this._pendingElement, transaction, this._context);
|
|
418
500
|
}
|
|
419
501
|
|
|
420
502
|
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
|
|
@@ -439,10 +521,18 @@ var ReactCompositeComponentMixin = {
|
|
|
439
521
|
*/
|
|
440
522
|
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
|
|
441
523
|
var inst = this._instance;
|
|
442
|
-
|
|
443
|
-
var nextContext
|
|
524
|
+
var willReceive = false;
|
|
525
|
+
var nextContext;
|
|
444
526
|
var nextProps;
|
|
445
527
|
|
|
528
|
+
// Determine if the context has changed or not
|
|
529
|
+
if (this._context === nextUnmaskedContext) {
|
|
530
|
+
nextContext = inst.context;
|
|
531
|
+
} else {
|
|
532
|
+
nextContext = this._processContext(nextUnmaskedContext);
|
|
533
|
+
willReceive = true;
|
|
534
|
+
}
|
|
535
|
+
|
|
446
536
|
// Distinguish between a props update versus a simple state update
|
|
447
537
|
if (prevParentElement === nextParentElement) {
|
|
448
538
|
// Skip checking prop types again -- we don't read inst.props to avoid
|
|
@@ -450,13 +540,14 @@ var ReactCompositeComponentMixin = {
|
|
|
450
540
|
nextProps = nextParentElement.props;
|
|
451
541
|
} else {
|
|
452
542
|
nextProps = this._processProps(nextParentElement.props);
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// immediately reconciled instead of waiting for the next batch.
|
|
543
|
+
willReceive = true;
|
|
544
|
+
}
|
|
456
545
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
546
|
+
// An update here will schedule an update but immediately set
|
|
547
|
+
// _pendingStateQueue which will ensure that any state updates gets
|
|
548
|
+
// immediately reconciled instead of waiting for the next batch.
|
|
549
|
+
if (willReceive && inst.componentWillReceiveProps) {
|
|
550
|
+
inst.componentWillReceiveProps(nextProps, nextContext);
|
|
460
551
|
}
|
|
461
552
|
|
|
462
553
|
var nextState = this._processPendingState(nextProps, nextContext);
|
|
@@ -464,7 +555,7 @@ var ReactCompositeComponentMixin = {
|
|
|
464
555
|
var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
465
556
|
|
|
466
557
|
if (process.env.NODE_ENV !== 'production') {
|
|
467
|
-
process.env.NODE_ENV !== 'production' ? warning(
|
|
558
|
+
process.env.NODE_ENV !== 'production' ? warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : void 0;
|
|
468
559
|
}
|
|
469
560
|
|
|
470
561
|
if (shouldUpdate) {
|
|
@@ -497,10 +588,10 @@ var ReactCompositeComponentMixin = {
|
|
|
497
588
|
return queue[0];
|
|
498
589
|
}
|
|
499
590
|
|
|
500
|
-
var nextState =
|
|
591
|
+
var nextState = _assign({}, replace ? queue[0] : inst.state);
|
|
501
592
|
for (var i = replace ? 1 : 0; i < queue.length; i++) {
|
|
502
593
|
var partial = queue[i];
|
|
503
|
-
|
|
594
|
+
_assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial);
|
|
504
595
|
}
|
|
505
596
|
|
|
506
597
|
return nextState;
|
|
@@ -561,22 +652,23 @@ var ReactCompositeComponentMixin = {
|
|
|
561
652
|
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
|
|
562
653
|
ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
|
|
563
654
|
} else {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
var prevComponentID = prevComponentInstance._rootNodeID;
|
|
567
|
-
ReactReconciler.unmountComponent(prevComponentInstance);
|
|
655
|
+
var oldNativeNode = ReactReconciler.getNativeNode(prevComponentInstance);
|
|
656
|
+
ReactReconciler.unmountComponent(prevComponentInstance, false);
|
|
568
657
|
|
|
658
|
+
this._renderedNodeType = ReactNodeTypes.getType(nextRenderedElement);
|
|
569
659
|
this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
|
|
570
|
-
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent,
|
|
571
|
-
this.
|
|
660
|
+
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, transaction, this._nativeParent, this._nativeContainerInfo, this._processChildContext(context));
|
|
661
|
+
this._replaceNodeWithMarkup(oldNativeNode, nextMarkup);
|
|
572
662
|
}
|
|
573
663
|
},
|
|
574
664
|
|
|
575
665
|
/**
|
|
666
|
+
* Overridden in shallow rendering.
|
|
667
|
+
*
|
|
576
668
|
* @protected
|
|
577
669
|
*/
|
|
578
|
-
|
|
579
|
-
ReactComponentEnvironment.
|
|
670
|
+
_replaceNodeWithMarkup: function (oldNativeNode, nextMarkup) {
|
|
671
|
+
ReactComponentEnvironment.replaceNodeWithMarkup(oldNativeNode, nextMarkup);
|
|
580
672
|
},
|
|
581
673
|
|
|
582
674
|
/**
|
|
@@ -587,7 +679,7 @@ var ReactCompositeComponentMixin = {
|
|
|
587
679
|
var renderedComponent = inst.render();
|
|
588
680
|
if (process.env.NODE_ENV !== 'production') {
|
|
589
681
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
590
|
-
if (
|
|
682
|
+
if (renderedComponent === undefined && inst.render._isMockFunction) {
|
|
591
683
|
// This is probably bad practice. Consider warning here and
|
|
592
684
|
// deprecating this convenience.
|
|
593
685
|
renderedComponent = null;
|
|
@@ -610,7 +702,7 @@ var ReactCompositeComponentMixin = {
|
|
|
610
702
|
}
|
|
611
703
|
!(
|
|
612
704
|
// TODO: An `isValidNode` function would probably be more appropriate
|
|
613
|
-
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid
|
|
705
|
+
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : void 0;
|
|
614
706
|
return renderedComponent;
|
|
615
707
|
},
|
|
616
708
|
|
|
@@ -624,11 +716,11 @@ var ReactCompositeComponentMixin = {
|
|
|
624
716
|
*/
|
|
625
717
|
attachRef: function (ref, component) {
|
|
626
718
|
var inst = this.getPublicInstance();
|
|
627
|
-
!(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) :
|
|
719
|
+
!(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) : void 0;
|
|
628
720
|
var publicComponentInstance = component.getPublicInstance();
|
|
629
721
|
if (process.env.NODE_ENV !== 'production') {
|
|
630
722
|
var componentName = component && component.getName ? component.getName() : 'a component';
|
|
631
|
-
process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) :
|
|
723
|
+
process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : void 0;
|
|
632
724
|
}
|
|
633
725
|
var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
|
|
634
726
|
refs[ref] = publicComponentInstance;
|