How to use measureLifeCyclePerf method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

60dc34ReactCompositeComponent.js

Source: 60dc34ReactCompositeComponent.js Github

copy
1
2
3
4
5
6
7
8
9
10
11
12'use strict';
13
14var React=require('React');
15var ReactComponentEnvironment=require('ReactComponentEnvironment');
16var ReactCurrentOwner=require('react/lib/ReactCurrentOwner');
17var ReactErrorUtils=require('ReactErrorUtils');
18var ReactInstanceMap=require('ReactInstanceMap');
19var ReactInstrumentation=require('ReactInstrumentation');
20var ReactNodeTypes=require('ReactNodeTypes');
21var ReactReconciler=require('ReactReconciler');
22
23if(__DEV__){
24var checkReactTypeSpec=require('checkReactTypeSpec');
25}
26
27var emptyObject=require('fbjs/lib/emptyObject');
28var invariant=require('fbjs/lib/invariant');
29var shallowEqual=require('fbjs/lib/shallowEqual');
30var shouldUpdateReactComponent=require('shouldUpdateReactComponent');
31var warning=require('fbjs/lib/warning');
32
33
34
35var CompositeTypes={
36ImpureClass:0,
37PureClass:1,
38StatelessFunctional:2};
39
40
41function StatelessComponent(Component){
42}
43StatelessComponent.prototype.render=function(){
44var Component=ReactInstanceMap.get(this)._currentElement.type;
45var element=Component(this.props,this.context,this.updater);
46warnIfInvalidElement(Component,element);
47return element;
48};
49
50function warnIfInvalidElement(Component,element){
51if(__DEV__){
52warning(
53element===null||element===false||React.isValidElement(element),
54'%s(...): A valid React element (or null) must be returned. You may have '+
55'returned undefined, an array or some other invalid object.',
56Component.displayName||Component.name||'Component');
57
58warning(
59!Component.childContextTypes,
60'%s(...): childContextTypes cannot be defined on a functional component.',
61Component.displayName||Component.name||'Component');
62
63}
64}
65
66function shouldConstruct(Component){
67return!!(Component.prototype&&Component.prototype.isReactComponent);
68}
69
70function isPureComponent(Component){
71return!!(Component.prototype&&Component.prototype.isPureReactComponent);
72}
73
74
75function measureLifeCyclePerf(fn,debugID,timerType){
76if(debugID===0){
77
78
79
80return fn();
81}
82
83ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID,timerType);
84try{
85return fn();
86}finally{
87ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID,timerType);
88}
89}
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124var nextMountID=1;
125
126
127
128
129var ReactCompositeComponent={
130
131
132
133
134
135
136
137
138construct:function construct(element){
139this._currentElement=element;
140this._rootNodeID=0;
141this._compositeType=null;
142this._instance=null;
143this._hostParent=null;
144this._hostContainerInfo=null;
145
146
147this._updateBatchNumber=null;
148this._pendingElement=null;
149this._pendingStateQueue=null;
150this._pendingReplaceState=false;
151this._pendingForceUpdate=false;
152
153this._renderedNodeType=null;
154this._renderedComponent=null;
155this._context=null;
156this._mountOrder=0;
157this._topLevelWrapper=null;
158
159
160this._pendingCallbacks=null;
161
162
163this._calledComponentWillUnmount=false;
164
165if(__DEV__){
166this._warnedAboutRefsInRender=false;
167}
168},
169
170
171
172
173
174
175
176
177
178
179
180
181mountComponent:function mountComponent(
182transaction,
183hostParent,
184hostContainerInfo,
185context)
186{var _this=this;
187this._context=context;
188this._mountOrder=nextMountID++;
189this._hostParent=hostParent;
190this._hostContainerInfo=hostContainerInfo;
191
192var publicProps=this._currentElement.props;
193var publicContext=this._processContext(context);
194
195var Component=this._currentElement.type;
196
197var updateQueue=transaction.getUpdateQueue();
198
199
200var doConstruct=shouldConstruct(Component);
201var inst=this._constructComponent(
202doConstruct,
203publicProps,
204publicContext,
205updateQueue);
206
207var renderedElement;
208
209
210if(!doConstruct&&(inst==null||inst.render==null)){
211renderedElement=inst;
212warnIfInvalidElement(Component,renderedElement);
213invariant(
214inst===null||
215inst===false||
216React.isValidElement(inst),
217'%s(...): A valid React element (or null) must be returned. You may have '+
218'returned undefined, an array or some other invalid object.',
219Component.displayName||Component.name||'Component');
220
221inst=new StatelessComponent(Component);
222this._compositeType=CompositeTypes.StatelessFunctional;
223}else{
224if(isPureComponent(Component)){
225this._compositeType=CompositeTypes.PureClass;
226}else{
227this._compositeType=CompositeTypes.ImpureClass;
228}
229}
230
231if(__DEV__){
232
233
234if(inst.render==null){
235warning(
236false,
237'%s(...): No `render` method found on the returned component '+
238'instance: you may have forgotten to define `render`.',
239Component.displayName||Component.name||'Component');
240
241}
242
243var propsMutated=inst.props!==publicProps;
244var componentName=
245Component.displayName||Component.name||'Component';
246
247warning(
248inst.props===undefined||!propsMutated,
249'%s(...): When calling super() in `%s`, make sure to pass '+
250'up the same props that your component\'s constructor was passed.',
251componentName,componentName);
252
253}
254
255
256
257inst.props=publicProps;
258inst.context=publicContext;
259inst.refs=emptyObject;
260inst.updater=updateQueue;
261
262this._instance=inst;
263
264
265ReactInstanceMap.set(inst,this);
266
267if(__DEV__){
268
269
270
271warning(
272!inst.getInitialState||
273inst.getInitialState.isReactClassApproved,
274'getInitialState was defined on %s, a plain JavaScript class. '+
275'This is only supported for classes created using React.createClass. '+
276'Did you mean to define a state property instead?',
277this.getName()||'a component');
278
279warning(
280!inst.getDefaultProps||
281inst.getDefaultProps.isReactClassApproved,
282'getDefaultProps was defined on %s, a plain JavaScript class. '+
283'This is only supported for classes created using React.createClass. '+
284'Use a static property to define defaultProps instead.',
285this.getName()||'a component');
286
287warning(
288!inst.propTypes,
289'propTypes was defined as an instance property on %s. Use a static '+
290'property to define propTypes instead.',
291this.getName()||'a component');
292
293warning(
294!inst.contextTypes,
295'contextTypes was defined as an instance property on %s. Use a '+
296'static property to define contextTypes instead.',
297this.getName()||'a component');
298
299warning(
300typeof inst.componentShouldUpdate!=='function',
301'%s has a method called '+
302'componentShouldUpdate(). Did you mean shouldComponentUpdate()? '+
303'The name is phrased as a question because the function is '+
304'expected to return a value.',
305this.getName()||'A component');
306
307warning(
308typeof inst.componentDidUnmount!=='function',
309'%s has a method called '+
310'componentDidUnmount(). But there is no such lifecycle method. '+
311'Did you mean componentWillUnmount()?',
312this.getName()||'A component');
313
314warning(
315typeof inst.componentWillRecieveProps!=='function',
316'%s has a method called '+
317'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
318this.getName()||'A component');
319
320}
321
322var initialState=inst.state;
323if(initialState===undefined){
324inst.state=initialState=null;
325}
326invariant(
327typeof initialState==='object'&&!Array.isArray(initialState),
328'%s.state: must be set to an object or null',
329this.getName()||'ReactCompositeComponent');
330
331
332this._pendingStateQueue=null;
333this._pendingReplaceState=false;
334this._pendingForceUpdate=false;
335
336var markup;
337if(inst.unstable_handleError){
338markup=this.performInitialMountWithErrorHandling(
339renderedElement,
340hostParent,
341hostContainerInfo,
342transaction,
343context);
344
345}else{
346markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
347}
348
349if(inst.componentDidMount){
350if(__DEV__){
351transaction.getReactMountReady().enqueue(function(){
352measureLifeCyclePerf(
353function(){return inst.componentDidMount();},
354_this._debugID,
355'componentDidMount');
356
357});
358}else{
359transaction.getReactMountReady().enqueue(inst.componentDidMount,inst);
360}
361}
362
363return markup;
364},
365
366_constructComponent:function _constructComponent(
367doConstruct,
368publicProps,
369publicContext,
370updateQueue)
371{
372if(__DEV__){
373ReactCurrentOwner.current=this;
374try{
375return this._constructComponentWithoutOwner(
376doConstruct,
377publicProps,
378publicContext,
379updateQueue);
380
381}finally{
382ReactCurrentOwner.current=null;
383}
384}else{
385return this._constructComponentWithoutOwner(
386doConstruct,
387publicProps,
388publicContext,
389updateQueue);
390
391}
392},
393
394_constructComponentWithoutOwner:function _constructComponentWithoutOwner(
395doConstruct,
396publicProps,
397publicContext,
398updateQueue)
399{
400var Component=this._currentElement.type;
401
402if(doConstruct){
403if(__DEV__){
404return measureLifeCyclePerf(
405function(){return new Component(publicProps,publicContext,updateQueue);},
406this._debugID,
407'ctor');
408
409}else{
410return new Component(publicProps,publicContext,updateQueue);
411}
412}
413
414
415
416if(__DEV__){
417return measureLifeCyclePerf(
418function(){return Component(publicProps,publicContext,updateQueue);},
419this._debugID,
420'render');
421
422}else{
423return Component(publicProps,publicContext,updateQueue);
424}
425},
426
427performInitialMountWithErrorHandling:function performInitialMountWithErrorHandling(
428renderedElement,
429hostParent,
430hostContainerInfo,
431transaction,
432context)
433{
434var markup;
435var checkpoint=transaction.checkpoint();
436try{
437markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
438}catch(e){
439
440transaction.rollback(checkpoint);
441this._instance.unstable_handleError(e);
442if(this._pendingStateQueue){
443this._instance.state=this._processPendingState(this._instance.props,this._instance.context);
444}
445checkpoint=transaction.checkpoint();
446
447this._renderedComponent.unmountComponent(true);
448transaction.rollback(checkpoint);
449
450
451
452markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
453}
454return markup;
455},
456
457performInitialMount:function performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context){
458var inst=this._instance;
459
460var debugID=0;
461if(__DEV__){
462debugID=this._debugID;
463}
464
465if(inst.componentWillMount){
466if(__DEV__){
467measureLifeCyclePerf(
468function(){return inst.componentWillMount();},
469debugID,
470'componentWillMount');
471
472}else{
473inst.componentWillMount();
474}
475
476
477if(this._pendingStateQueue){
478inst.state=this._processPendingState(inst.props,inst.context);
479}
480}
481
482
483if(renderedElement===undefined){
484renderedElement=this._renderValidatedComponent();
485}
486
487var nodeType=ReactNodeTypes.getType(renderedElement);
488this._renderedNodeType=nodeType;
489var child=this._instantiateReactComponent(
490renderedElement,
491nodeType!==ReactNodeTypes.EMPTY);
492
493this._renderedComponent=child;
494
495var markup=ReactReconciler.mountComponent(
496child,
497transaction,
498hostParent,
499hostContainerInfo,
500this._processChildContext(context),
501debugID);
502
503
504if(__DEV__){
505if(debugID!==0){
506var childDebugIDs=child._debugID!==0?[child._debugID]:[];
507ReactInstrumentation.debugTool.onSetChildren(debugID,childDebugIDs);
508}
509}
510
511return markup;
512},
513
514getHostNode:function getHostNode(){
515return ReactReconciler.getHostNode(this._renderedComponent);
516},
517
518
519
520
521
522
523
524unmountComponent:function unmountComponent(safely){
525if(!this._renderedComponent){
526return;
527}
528
529var inst=this._instance;
530
531if(inst.componentWillUnmount&&!inst._calledComponentWillUnmount){
532inst._calledComponentWillUnmount=true;
533
534if(safely){
535var name=this.getName()+'.componentWillUnmount()';
536ReactErrorUtils.invokeGuardedCallback(name,inst.componentWillUnmount.bind(inst));
537}else{
538if(__DEV__){
539measureLifeCyclePerf(
540function(){return inst.componentWillUnmount();},
541this._debugID,
542'componentWillUnmount');
543
544}else{
545inst.componentWillUnmount();
546}
547}
548}
549
550if(this._renderedComponent){
551ReactReconciler.unmountComponent(this._renderedComponent,safely);
552this._renderedNodeType=null;
553this._renderedComponent=null;
554this._instance=null;
555}
556
557
558
559
560this._pendingStateQueue=null;
561this._pendingReplaceState=false;
562this._pendingForceUpdate=false;
563this._pendingCallbacks=null;
564this._pendingElement=null;
565
566
567
568this._context=null;
569this._rootNodeID=0;
570this._topLevelWrapper=null;
571
572
573
574
575ReactInstanceMap.remove(inst);
576
577
578
579
580
581
582},
583
584
585
586
587
588
589
590
591
592_maskContext:function _maskContext(context){
593var Component=this._currentElement.type;
594var contextTypes=Component.contextTypes;
595if(!contextTypes){
596return emptyObject;
597}
598var maskedContext={};
599for(var contextName in contextTypes){
600maskedContext[contextName]=context[contextName];
601}
602return maskedContext;
603},
604
605
606
607
608
609
610
611
612
613_processContext:function _processContext(context){
614var maskedContext=this._maskContext(context);
615if(__DEV__){
616var Component=this._currentElement.type;
617if(Component.contextTypes){
618this._checkContextTypes(
619Component.contextTypes,
620maskedContext,
621'context');
622
623}
624}
625return maskedContext;
626},
627
628
629
630
631
632
633_processChildContext:function _processChildContext(currentContext){
634var Component=this._currentElement.type;
635var inst=this._instance;
636var childContext;
637
638if(inst.getChildContext){
639if(__DEV__){
640ReactInstrumentation.debugTool.onBeginProcessingChildContext();
641try{
642childContext=inst.getChildContext();
643}finally{
644ReactInstrumentation.debugTool.onEndProcessingChildContext();
645}
646}else{
647childContext=inst.getChildContext();
648}
649}
650
651if(childContext){
652invariant(
653typeof Component.childContextTypes==='object',
654'%s.getChildContext(): childContextTypes must be defined in order to '+
655'use getChildContext().',
656this.getName()||'ReactCompositeComponent');
657
658if(__DEV__){
659this._checkContextTypes(
660Component.childContextTypes,
661childContext,
662'childContext');
663
664}
665for(var name in childContext){
666invariant(
667name in Component.childContextTypes,
668'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
669this.getName()||'ReactCompositeComponent',
670name);
671
672}
673return babelHelpers.extends({},currentContext,childContext);
674}
675return currentContext;
676},
677
678
679
680
681
682
683
684
685
686_checkContextTypes:function _checkContextTypes(
687typeSpecs,
688values,
689location)
690{
691if(__DEV__){
692checkReactTypeSpec(
693typeSpecs,
694values,
695location,
696this.getName(),
697null,
698this._debugID);
699
700}
701},
702
703receiveComponent:function receiveComponent(nextElement,transaction,nextContext){
704var prevElement=this._currentElement;
705var prevContext=this._context;
706
707this._pendingElement=null;
708
709this.updateComponent(
710transaction,
711prevElement,
712nextElement,
713prevContext,
714nextContext);
715
716},
717
718
719
720
721
722
723
724
725performUpdateIfNecessary:function performUpdateIfNecessary(transaction){
726if(this._pendingElement!=null){
727ReactReconciler.receiveComponent(
728this,
729this._pendingElement,
730transaction,
731this._context);
732
733}else if(this._pendingStateQueue!==null||this._pendingForceUpdate){
734this.updateComponent(
735transaction,
736this._currentElement,
737this._currentElement,
738this._context,
739this._context);
740
741}else{
742this._updateBatchNumber=null;
743}
744},
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761updateComponent:function updateComponent(
762transaction,
763prevParentElement,
764nextParentElement,
765prevUnmaskedContext,
766nextUnmaskedContext)
767{
768var inst=this._instance;
769invariant(
770inst!=null,
771'Attempted to update component `%s` that has already been unmounted '+
772'(or failed to mount).',
773this.getName()||'ReactCompositeComponent');
774
775
776var willReceive=false;
777var nextContext;
778
779
780if(this._context===nextUnmaskedContext){
781nextContext=inst.context;
782}else{
783nextContext=this._processContext(nextUnmaskedContext);
784willReceive=true;
785}
786
787var prevProps=prevParentElement.props;
788var nextProps=nextParentElement.props;
789
790
791if(prevParentElement!==nextParentElement){
792willReceive=true;
793}
794
795
796
797
798if(willReceive&&inst.componentWillReceiveProps){
799if(__DEV__){
800measureLifeCyclePerf(
801function(){return inst.componentWillReceiveProps(nextProps,nextContext);},
802this._debugID,
803'componentWillReceiveProps');
804
805}else{
806inst.componentWillReceiveProps(nextProps,nextContext);
807}
808}
809
810var nextState=this._processPendingState(nextProps,nextContext);
811var shouldUpdate=true;
812
813if(!this._pendingForceUpdate){
814if(inst.shouldComponentUpdate){
815if(__DEV__){
816shouldUpdate=measureLifeCyclePerf(
817function(){return inst.shouldComponentUpdate(nextProps,nextState,nextContext);},
818this._debugID,
819'shouldComponentUpdate');
820
821}else{
822shouldUpdate=inst.shouldComponentUpdate(nextProps,nextState,nextContext);
823}
824}else{
825if(this._compositeType===CompositeTypes.PureClass){
826shouldUpdate=
827!shallowEqual(prevProps,nextProps)||
828!shallowEqual(inst.state,nextState);
829}
830}
831}
832
833if(__DEV__){
834warning(
835shouldUpdate!==undefined,
836'%s.shouldComponentUpdate(): Returned undefined instead of a '+
837'boolean value. Make sure to return true or false.',
838this.getName()||'ReactCompositeComponent');
839
840}
841
842this._updateBatchNumber=null;
843if(shouldUpdate){
844this._pendingForceUpdate=false;
845
846this._performComponentUpdate(
847nextParentElement,
848nextProps,
849nextState,
850nextContext,
851transaction,
852nextUnmaskedContext);
853
854}else{
855
856
857this._currentElement=nextParentElement;
858this._context=nextUnmaskedContext;
859inst.props=nextProps;
860inst.state=nextState;
861inst.context=nextContext;
862}
863},
864
865_processPendingState:function _processPendingState(props,context){
866var inst=this._instance;
867var queue=this._pendingStateQueue;
868var replace=this._pendingReplaceState;
869this._pendingReplaceState=false;
870this._pendingStateQueue=null;
871
872if(!queue){
873return inst.state;
874}
875
876if(replace&&queue.length===1){
877return queue[0];
878}
879
880var nextState=babelHelpers.extends({},replace?queue[0]:inst.state);
881for(var i=replace?1:0;i<queue.length;i++){
882var partial=queue[i];
883babelHelpers.extends(
884nextState,
885typeof partial==='function'?
886partial.call(inst,nextState,props,context):
887partial);
888
889}
890
891return nextState;
892},
893
894
895
896
897
898
899
900
901
902
903
904
905
906_performComponentUpdate:function _performComponentUpdate(
907nextElement,
908nextProps,
909nextState,
910nextContext,
911transaction,
912unmaskedContext)
913{var _this2=this;
914var inst=this._instance;
915
916var hasComponentDidUpdate=Boolean(inst.componentDidUpdate);
917var prevProps;
918var prevState;
919var prevContext;
920if(hasComponentDidUpdate){
921prevProps=inst.props;
922prevState=inst.state;
923prevContext=inst.context;
924}
925
926if(inst.componentWillUpdate){
927if(__DEV__){
928measureLifeCyclePerf(
929function(){return inst.componentWillUpdate(nextProps,nextState,nextContext);},
930this._debugID,
931'componentWillUpdate');
932
933}else{
934inst.componentWillUpdate(nextProps,nextState,nextContext);
935}
936}
937
938this._currentElement=nextElement;
939this._context=unmaskedContext;
940inst.props=nextProps;
941inst.state=nextState;
942inst.context=nextContext;
943
944this._updateRenderedComponent(transaction,unmaskedContext);
945
946if(hasComponentDidUpdate){
947if(__DEV__){
948transaction.getReactMountReady().enqueue(function(){
949measureLifeCyclePerf(
950inst.componentDidUpdate.bind(inst,prevProps,prevState,prevContext),
951_this2._debugID,
952'componentDidUpdate');
953
954});
955}else{
956transaction.getReactMountReady().enqueue(
957inst.componentDidUpdate.bind(inst,prevProps,prevState,prevContext),
958inst);
959
960}
961}
962},
963
964
965
966
967
968
969
970_updateRenderedComponent:function _updateRenderedComponent(transaction,context){
971var prevComponentInstance=this._renderedComponent;
972var prevRenderedElement=prevComponentInstance._currentElement;
973var nextRenderedElement=this._renderValidatedComponent();
974
975var debugID=0;
976if(__DEV__){
977debugID=this._debugID;
978}
979
980if(shouldUpdateReactComponent(prevRenderedElement,nextRenderedElement)){
981ReactReconciler.receiveComponent(
982prevComponentInstance,
983nextRenderedElement,
984transaction,
985this._processChildContext(context));
986
987}else{
988var oldHostNode=ReactReconciler.getHostNode(prevComponentInstance);
989ReactReconciler.unmountComponent(prevComponentInstance,false);
990
991var nodeType=ReactNodeTypes.getType(nextRenderedElement);
992this._renderedNodeType=nodeType;
993var child=this._instantiateReactComponent(
994nextRenderedElement,
995nodeType!==ReactNodeTypes.EMPTY);
996
997this._renderedComponent=child;
998
999var nextMarkup=ReactReconciler.mountComponent(
1000child,
1001transaction,
1002this._hostParent,
1003this._hostContainerInfo,
1004this._processChildContext(context),
1005debugID);
1006
1007
1008if(__DEV__){
1009if(debugID!==0){
1010var childDebugIDs=child._debugID!==0?[child._debugID]:[];
1011ReactInstrumentation.debugTool.onSetChildren(debugID,childDebugIDs);
1012}
1013}
1014
1015this._replaceNodeWithMarkup(
1016oldHostNode,
1017nextMarkup,
1018prevComponentInstance);
1019
1020}
1021},
1022
1023
1024
1025
1026
1027
1028_replaceNodeWithMarkup:function _replaceNodeWithMarkup(oldHostNode,nextMarkup,prevInstance){
1029ReactComponentEnvironment.replaceNodeWithMarkup(
1030oldHostNode,
1031nextMarkup,
1032prevInstance);
1033
1034},
1035
1036
1037
1038
1039_renderValidatedComponentWithoutOwnerOrContext:function _renderValidatedComponentWithoutOwnerOrContext(){
1040var inst=this._instance;
1041var renderedElement;
1042
1043if(__DEV__){
1044renderedElement=measureLifeCyclePerf(
1045function(){return inst.render();},
1046this._debugID,
1047'render');
1048
1049}else{
1050renderedElement=inst.render();
1051}
1052
1053if(__DEV__){
1054
1055if(renderedElement===undefined&&
1056inst.render._isMockFunction){
1057
1058
1059renderedElement=null;
1060}
1061}
1062
1063return renderedElement;
1064},
1065
1066
1067
1068
1069_renderValidatedComponent:function _renderValidatedComponent(){
1070var renderedElement;
1071if(__DEV__||this._compositeType!==CompositeTypes.StatelessFunctional){
1072ReactCurrentOwner.current=this;
1073try{
1074renderedElement=
1075this._renderValidatedComponentWithoutOwnerOrContext();
1076}finally{
1077ReactCurrentOwner.current=null;
1078}
1079}else{
1080renderedElement=
1081this._renderValidatedComponentWithoutOwnerOrContext();
1082}
1083invariant(
1084
1085renderedElement===null||renderedElement===false||
1086React.isValidElement(renderedElement),
1087'%s.render(): A valid React element (or null) must be returned. You may have '+
1088'returned undefined, an array or some other invalid object.',
1089this.getName()||'ReactCompositeComponent');
1090
1091
1092return renderedElement;
1093},
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103attachRef:function attachRef(ref,component,transaction){
1104var inst=this.getPublicInstance();
1105invariant(inst!=null,'Stateless function components cannot have refs.');
1106var publicComponentInstance=component.getPublicInstance(transaction);
1107if(__DEV__){
1108var componentName=component&&component.getName?
1109component.getName():'a component';
1110warning(
1111publicComponentInstance!=null||
1112component._compositeType!==CompositeTypes.StatelessFunctional,
1113'Stateless function components cannot be given refs '+
1114'(See ref "%s" in %s created by %s). '+
1115'Attempts to access this ref will fail.',
1116ref,
1117componentName,
1118this.getName());
1119
1120}
1121var refs=inst.refs===emptyObject?inst.refs={}:inst.refs;
1122refs[ref]=publicComponentInstance;
1123},
1124
1125
1126
1127
1128
1129
1130
1131
1132detachRef:function detachRef(ref){
1133var refs=this.getPublicInstance().refs;
1134delete refs[ref];
1135},
1136
1137
1138
1139
1140
1141
1142
1143getName:function getName(){
1144var type=this._currentElement.type;
1145var constructor=this._instance&&this._instance.constructor;
1146return(
1147type.displayName||constructor&&constructor.displayName||
1148type.name||constructor&&constructor.name||
1149null);
1150
1151},
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161getPublicInstance:function getPublicInstance(){
1162var inst=this._instance;
1163if(this._compositeType===CompositeTypes.StatelessFunctional){
1164return null;
1165}
1166return inst;
1167},
1168
1169
1170_instantiateReactComponent:null};
1171
1172
1173
1174module.exports=ReactCompositeComponent;
Full Screen

cc0b4eReactCompositeComponent.js

Source: cc0b4eReactCompositeComponent.js Github

copy
1
2
3
4
5
6
7
8
9
10
11
12'use strict';
13
14var React=require('React');
15var ReactComponentEnvironment=require('ReactComponentEnvironment');
16var ReactCurrentOwner=require('react/lib/ReactCurrentOwner');
17var ReactErrorUtils=require('ReactErrorUtils');
18var ReactInstanceMap=require('ReactInstanceMap');
19var ReactInstrumentation=require('ReactInstrumentation');
20var ReactNodeTypes=require('ReactNodeTypes');
21var ReactReconciler=require('ReactReconciler');
22
23if(__DEV__){
24var checkReactTypeSpec=require('checkReactTypeSpec');
25}
26
27var emptyObject=require('fbjs/lib/emptyObject');
28var invariant=require('fbjs/lib/invariant');
29var shallowEqual=require('fbjs/lib/shallowEqual');
30var shouldUpdateReactComponent=require('shouldUpdateReactComponent');
31var warning=require('fbjs/lib/warning');
32
33
34
35var CompositeTypes={
36ImpureClass:0,
37PureClass:1,
38StatelessFunctional:2};
39
40
41function StatelessComponent(Component){
42}
43StatelessComponent.prototype.render=function(){
44var Component=ReactInstanceMap.get(this)._currentElement.type;
45var element=Component(this.props,this.context,this.updater);
46warnIfInvalidElement(Component,element);
47return element;
48};
49
50function warnIfInvalidElement(Component,element){
51if(__DEV__){
52warning(
53element===null||element===false||React.isValidElement(element),
54'%s(...): A valid React element (or null) must be returned. You may have '+
55'returned undefined, an array or some other invalid object.',
56Component.displayName||Component.name||'Component');
57
58warning(
59!Component.childContextTypes,
60'%s(...): childContextTypes cannot be defined on a functional component.',
61Component.displayName||Component.name||'Component');
62
63}
64}
65
66function shouldConstruct(Component){
67return!!(Component.prototype&&Component.prototype.isReactComponent);
68}
69
70function isPureComponent(Component){
71return!!(Component.prototype&&Component.prototype.isPureReactComponent);
72}
73
74
75function measureLifeCyclePerf(fn,debugID,timerType){
76if(debugID===0){
77
78
79
80return fn();
81}
82
83ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID,timerType);
84try{
85return fn();
86}finally{
87ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID,timerType);
88}
89}
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124var nextMountID=1;
125
126
127
128
129var ReactCompositeComponent={
130
131
132
133
134
135
136
137
138construct:function construct(element){
139this._currentElement=element;
140this._rootNodeID=0;
141this._compositeType=null;
142this._instance=null;
143this._hostParent=null;
144this._hostContainerInfo=null;
145
146
147this._updateBatchNumber=null;
148this._pendingElement=null;
149this._pendingStateQueue=null;
150this._pendingReplaceState=false;
151this._pendingForceUpdate=false;
152
153this._renderedNodeType=null;
154this._renderedComponent=null;
155this._context=null;
156this._mountOrder=0;
157this._topLevelWrapper=null;
158
159
160this._pendingCallbacks=null;
161
162
163this._calledComponentWillUnmount=false;
164
165if(__DEV__){
166this._warnedAboutRefsInRender=false;
167}
168},
169
170
171
172
173
174
175
176
177
178
179
180
181mountComponent:function mountComponent(
182transaction,
183hostParent,
184hostContainerInfo,
185context)
186{var _this=this;
187this._context=context;
188this._mountOrder=nextMountID++;
189this._hostParent=hostParent;
190this._hostContainerInfo=hostContainerInfo;
191
192var publicProps=this._currentElement.props;
193var publicContext=this._processContext(context);
194
195var Component=this._currentElement.type;
196
197var updateQueue=transaction.getUpdateQueue();
198
199
200var doConstruct=shouldConstruct(Component);
201var inst=this._constructComponent(
202doConstruct,
203publicProps,
204publicContext,
205updateQueue);
206
207var renderedElement;
208
209
210if(!doConstruct&&(inst==null||inst.render==null)){
211renderedElement=inst;
212warnIfInvalidElement(Component,renderedElement);
213invariant(
214inst===null||
215inst===false||
216React.isValidElement(inst),
217'%s(...): A valid React element (or null) must be returned. You may have '+
218'returned undefined, an array or some other invalid object.',
219Component.displayName||Component.name||'Component');
220
221inst=new StatelessComponent(Component);
222this._compositeType=CompositeTypes.StatelessFunctional;
223}else{
224if(isPureComponent(Component)){
225this._compositeType=CompositeTypes.PureClass;
226}else{
227this._compositeType=CompositeTypes.ImpureClass;
228}
229}
230
231if(__DEV__){
232
233
234if(inst.render==null){
235warning(
236false,
237'%s(...): No `render` method found on the returned component '+
238'instance: you may have forgotten to define `render`.',
239Component.displayName||Component.name||'Component');
240
241}
242
243var propsMutated=inst.props!==publicProps;
244var componentName=
245Component.displayName||Component.name||'Component';
246
247warning(
248inst.props===undefined||!propsMutated,
249'%s(...): When calling super() in `%s`, make sure to pass '+
250'up the same props that your component\'s constructor was passed.',
251componentName,componentName);
252
253}
254
255
256
257inst.props=publicProps;
258inst.context=publicContext;
259inst.refs=emptyObject;
260inst.updater=updateQueue;
261
262this._instance=inst;
263
264
265ReactInstanceMap.set(inst,this);
266
267if(__DEV__){
268
269
270
271warning(
272!inst.getInitialState||
273inst.getInitialState.isReactClassApproved,
274'getInitialState was defined on %s, a plain JavaScript class. '+
275'This is only supported for classes created using React.createClass. '+
276'Did you mean to define a state property instead?',
277this.getName()||'a component');
278
279warning(
280!inst.getDefaultProps||
281inst.getDefaultProps.isReactClassApproved,
282'getDefaultProps was defined on %s, a plain JavaScript class. '+
283'This is only supported for classes created using React.createClass. '+
284'Use a static property to define defaultProps instead.',
285this.getName()||'a component');
286
287warning(
288!inst.propTypes,
289'propTypes was defined as an instance property on %s. Use a static '+
290'property to define propTypes instead.',
291this.getName()||'a component');
292
293warning(
294!inst.contextTypes,
295'contextTypes was defined as an instance property on %s. Use a '+
296'static property to define contextTypes instead.',
297this.getName()||'a component');
298
299warning(
300typeof inst.componentShouldUpdate!=='function',
301'%s has a method called '+
302'componentShouldUpdate(). Did you mean shouldComponentUpdate()? '+
303'The name is phrased as a question because the function is '+
304'expected to return a value.',
305this.getName()||'A component');
306
307warning(
308typeof inst.componentDidUnmount!=='function',
309'%s has a method called '+
310'componentDidUnmount(). But there is no such lifecycle method. '+
311'Did you mean componentWillUnmount()?',
312this.getName()||'A component');
313
314warning(
315typeof inst.componentWillRecieveProps!=='function',
316'%s has a method called '+
317'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
318this.getName()||'A component');
319
320}
321
322var initialState=inst.state;
323if(initialState===undefined){
324inst.state=initialState=null;
325}
326invariant(
327typeof initialState==='object'&&!Array.isArray(initialState),
328'%s.state: must be set to an object or null',
329this.getName()||'ReactCompositeComponent');
330
331
332this._pendingStateQueue=null;
333this._pendingReplaceState=false;
334this._pendingForceUpdate=false;
335
336var markup;
337if(inst.unstable_handleError){
338markup=this.performInitialMountWithErrorHandling(
339renderedElement,
340hostParent,
341hostContainerInfo,
342transaction,
343context);
344
345}else{
346markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
347}
348
349if(inst.componentDidMount){
350if(__DEV__){
351transaction.getReactMountReady().enqueue(function(){
352measureLifeCyclePerf(
353function(){return inst.componentDidMount();},
354_this._debugID,
355'componentDidMount');
356
357});
358}else{
359transaction.getReactMountReady().enqueue(inst.componentDidMount,inst);
360}
361}
362
363return markup;
364},
365
366_constructComponent:function _constructComponent(
367doConstruct,
368publicProps,
369publicContext,
370updateQueue)
371{
372if(__DEV__){
373ReactCurrentOwner.current=this;
374try{
375return this._constructComponentWithoutOwner(
376doConstruct,
377publicProps,
378publicContext,
379updateQueue);
380
381}finally{
382ReactCurrentOwner.current=null;
383}
384}else{
385return this._constructComponentWithoutOwner(
386doConstruct,
387publicProps,
388publicContext,
389updateQueue);
390
391}
392},
393
394_constructComponentWithoutOwner:function _constructComponentWithoutOwner(
395doConstruct,
396publicProps,
397publicContext,
398updateQueue)
399{
400var Component=this._currentElement.type;
401
402if(doConstruct){
403if(__DEV__){
404return measureLifeCyclePerf(
405function(){return new Component(publicProps,publicContext,updateQueue);},
406this._debugID,
407'ctor');
408
409}else{
410return new Component(publicProps,publicContext,updateQueue);
411}
412}
413
414
415
416if(__DEV__){
417return measureLifeCyclePerf(
418function(){return Component(publicProps,publicContext,updateQueue);},
419this._debugID,
420'render');
421
422}else{
423return Component(publicProps,publicContext,updateQueue);
424}
425},
426
427performInitialMountWithErrorHandling:function performInitialMountWithErrorHandling(
428renderedElement,
429hostParent,
430hostContainerInfo,
431transaction,
432context)
433{
434var markup;
435var checkpoint=transaction.checkpoint();
436try{
437markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
438}catch(e){
439
440transaction.rollback(checkpoint);
441this._instance.unstable_handleError(e);
442if(this._pendingStateQueue){
443this._instance.state=this._processPendingState(this._instance.props,this._instance.context);
444}
445checkpoint=transaction.checkpoint();
446
447this._renderedComponent.unmountComponent(true);
448transaction.rollback(checkpoint);
449
450
451
452markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
453}
454return markup;
455},
456
457performInitialMount:function performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context){
458var inst=this._instance;
459
460var debugID=0;
461if(__DEV__){
462debugID=this._debugID;
463}
464
465if(inst.componentWillMount){
466if(__DEV__){
467measureLifeCyclePerf(
468function(){return inst.componentWillMount();},
469debugID,
470'componentWillMount');
471
472}else{
473inst.componentWillMount();
474}
475
476
477if(this._pendingStateQueue){
478inst.state=this._processPendingState(inst.props,inst.context);
479}
480}
481
482
483if(renderedElement===undefined){
484renderedElement=this._renderValidatedComponent();
485}
486
487var nodeType=ReactNodeTypes.getType(renderedElement);
488this._renderedNodeType=nodeType;
489var child=this._instantiateReactComponent(
490renderedElement,
491nodeType!==ReactNodeTypes.EMPTY);
492
493this._renderedComponent=child;
494
495var markup=ReactReconciler.mountComponent(
496child,
497transaction,
498hostParent,
499hostContainerInfo,
500this._processChildContext(context),
501debugID);
502
503
504if(__DEV__){
505if(debugID!==0){
506var childDebugIDs=child._debugID!==0?[child._debugID]:[];
507ReactInstrumentation.debugTool.onSetChildren(debugID,childDebugIDs);
508}
509}
510
511return markup;
512},
513
514getHostNode:function getHostNode(){
515return ReactReconciler.getHostNode(this._renderedComponent);
516},
517
518
519
520
521
522
523
524unmountComponent:function unmountComponent(safely){
525if(!this._renderedComponent){
526return;
527}
528
529var inst=this._instance;
530
531if(inst.componentWillUnmount&&!inst._calledComponentWillUnmount){
532inst._calledComponentWillUnmount=true;
533
534if(safely){
535var name=this.getName()+'.componentWillUnmount()';
536ReactErrorUtils.invokeGuardedCallback(name,inst.componentWillUnmount.bind(inst));
537}else{
538if(__DEV__){
539measureLifeCyclePerf(
540function(){return inst.componentWillUnmount();},
541this._debugID,
542'componentWillUnmount');
543
544}else{
545inst.componentWillUnmount();
546}
547}
548}
549
550if(this._renderedComponent){
551ReactReconciler.unmountComponent(this._renderedComponent,safely);
552this._renderedNodeType=null;
553this._renderedComponent=null;
554this._instance=null;
555}
556
557
558
559
560this._pendingStateQueue=null;
561this._pendingReplaceState=false;
562this._pendingForceUpdate=false;
563this._pendingCallbacks=null;
564this._pendingElement=null;
565
566
567
568this._context=null;
569this._rootNodeID=0;
570this._topLevelWrapper=null;
571
572
573
574
575ReactInstanceMap.remove(inst);
576
577
578
579
580
581
582},
583
584
585
586
587
588
589
590
591
592_maskContext:function _maskContext(context){
593var Component=this._currentElement.type;
594var contextTypes=Component.contextTypes;
595if(!contextTypes){
596return emptyObject;
597}
598var maskedContext={};
599for(var contextName in contextTypes){
600maskedContext[contextName]=context[contextName];
601}
602return maskedContext;
603},
604
605
606
607
608
609
610
611
612
613_processContext:function _processContext(context){
614var maskedContext=this._maskContext(context);
615if(__DEV__){
616var Component=this._currentElement.type;
617if(Component.contextTypes){
618this._checkContextTypes(
619Component.contextTypes,
620maskedContext,
621'context');
622
623}
624}
625return maskedContext;
626},
627
628
629
630
631
632
633_processChildContext:function _processChildContext(currentContext){
634var Component=this._currentElement.type;
635var inst=this._instance;
636var childContext;
637
638if(inst.getChildContext){
639if(__DEV__){
640ReactInstrumentation.debugTool.onBeginProcessingChildContext();
641try{
642childContext=inst.getChildContext();
643}finally{
644ReactInstrumentation.debugTool.onEndProcessingChildContext();
645}
646}else{
647childContext=inst.getChildContext();
648}
649}
650
651if(childContext){
652invariant(
653typeof Component.childContextTypes==='object',
654'%s.getChildContext(): childContextTypes must be defined in order to '+
655'use getChildContext().',
656this.getName()||'ReactCompositeComponent');
657
658if(__DEV__){
659this._checkContextTypes(
660Component.childContextTypes,
661childContext,
662'childContext');
663
664}
665for(var name in childContext){
666invariant(
667name in Component.childContextTypes,
668'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
669this.getName()||'ReactCompositeComponent',
670name);
671
672}
673return babelHelpers.extends({},currentContext,childContext);
674}
675return currentContext;
676},
677
678
679
680
681
682
683
684
685
686_checkContextTypes:function _checkContextTypes(
687typeSpecs,
688values,
689location)
690{
691if(__DEV__){
692checkReactTypeSpec(
693typeSpecs,
694values,
695location,
696this.getName(),
697null,
698this._debugID);
699
700}
701},
702
703receiveComponent:function receiveComponent(nextElement,transaction,nextContext){
704var prevElement=this._currentElement;
705var prevContext=this._context;
706
707this._pendingElement=null;
708
709this.updateComponent(
710transaction,
711prevElement,
712nextElement,
713prevContext,
714nextContext);
715
716},
717
718
719
720
721
722
723
724
725performUpdateIfNecessary:function performUpdateIfNecessary(transaction){
726if(this._pendingElement!=null){
727ReactReconciler.receiveComponent(
728this,
729this._pendingElement,
730transaction,
731this._context);
732
733}else if(this._pendingStateQueue!==null||this._pendingForceUpdate){
734this.updateComponent(
735transaction,
736this._currentElement,
737this._currentElement,
738this._context,
739this._context);
740
741}else{
742this._updateBatchNumber=null;
743}
744},
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761updateComponent:function updateComponent(
762transaction,
763prevParentElement,
764nextParentElement,
765prevUnmaskedContext,
766nextUnmaskedContext)
767{
768var inst=this._instance;
769invariant(
770inst!=null,
771'Attempted to update component `%s` that has already been unmounted '+
772'(or failed to mount).',
773this.getName()||'ReactCompositeComponent');
774
775
776var willReceive=false;
777var nextContext;
778
779
780if(this._context===nextUnmaskedContext){
781nextContext=inst.context;
782}else{
783nextContext=this._processContext(nextUnmaskedContext);
784willReceive=true;
785}
786
787var prevProps=prevParentElement.props;
788var nextProps=nextParentElement.props;
789
790
791if(prevParentElement!==nextParentElement){
792willReceive=true;
793}
794
795
796
797
798if(willReceive&&inst.componentWillReceiveProps){
799if(__DEV__){
800measureLifeCyclePerf(
801function(){return inst.componentWillReceiveProps(nextProps,nextContext);},
802this._debugID,
803'componentWillReceiveProps');
804
805}else{
806inst.componentWillReceiveProps(nextProps,nextContext);
807}
808}
809
810var nextState=this._processPendingState(nextProps,nextContext);
811var shouldUpdate=true;
812
813if(!this._pendingForceUpdate){
814if(inst.shouldComponentUpdate){
815if(__DEV__){
816shouldUpdate=measureLifeCyclePerf(
817function(){return inst.shouldComponentUpdate(nextProps,nextState,nextContext);},
818this._debugID,
819'shouldComponentUpdate');
820
821}else{
822shouldUpdate=inst.shouldComponentUpdate(nextProps,nextState,nextContext);
823}
824}else{
825if(this._compositeType===CompositeTypes.PureClass){
826shouldUpdate=
827!shallowEqual(prevProps,nextProps)||
828!shallowEqual(inst.state,nextState);
829}
830}
831}
832
833if(__DEV__){
834warning(
835shouldUpdate!==undefined,
836'%s.shouldComponentUpdate(): Returned undefined instead of a '+
837'boolean value. Make sure to return true or false.',
838this.getName()||'ReactCompositeComponent');
839
840}
841
842this._updateBatchNumber=null;
843if(shouldUpdate){
844this._pendingForceUpdate=false;
845
846this._performComponentUpdate(
847nextParentElement,
848nextProps,
849nextState,
850nextContext,
851transaction,
852nextUnmaskedContext);
853
854}else{
855
856
857this._currentElement=nextParentElement;
858this._context=nextUnmaskedContext;
859inst.props=nextProps;
860inst.state=nextState;
861inst.context=nextContext;
862}
863},
864
865_processPendingState:function _processPendingState(props,context){
866var inst=this._instance;
867var queue=this._pendingStateQueue;
868var replace=this._pendingReplaceState;
869this._pendingReplaceState=false;
870this._pendingStateQueue=null;
871
872if(!queue){
873return inst.state;
874}
875
876if(replace&&queue.length===1){
877return queue[0];
878}
879
880var nextState=babelHelpers.extends({},replace?queue[0]:inst.state);
881for(var i=replace?1:0;i<queue.length;i++){
882var partial=queue[i];
883babelHelpers.extends(
884nextState,
885typeof partial==='function'?
886partial.call(inst,nextState,props,context):
887partial);
888
889}
890
891return nextState;
892},
893
894
895
896
897
898
899
900
901
902
903
904
905
906_performComponentUpdate:function _performComponentUpdate(
907nextElement,
908nextProps,
909nextState,
910nextContext,
911transaction,
912unmaskedContext)
913{var _this2=this;
914var inst=this._instance;
915
916var hasComponentDidUpdate=Boolean(inst.componentDidUpdate);
917var prevProps;
918var prevState;
919var prevContext;
920if(hasComponentDidUpdate){
921prevProps=inst.props;
922prevState=inst.state;
923prevContext=inst.context;
924}
925
926if(inst.componentWillUpdate){
927if(__DEV__){
928measureLifeCyclePerf(
929function(){return inst.componentWillUpdate(nextProps,nextState,nextContext);},
930this._debugID,
931'componentWillUpdate');
932
933}else{
934inst.componentWillUpdate(nextProps,nextState,nextContext);
935}
936}
937
938this._currentElement=nextElement;
939this._context=unmaskedContext;
940inst.props=nextProps;
941inst.state=nextState;
942inst.context=nextContext;
943
944this._updateRenderedComponent(transaction,unmaskedContext);
945
946if(hasComponentDidUpdate){
947if(__DEV__){
948transaction.getReactMountReady().enqueue(function(){
949measureLifeCyclePerf(
950inst.componentDidUpdate.bind(inst,prevProps,prevState,prevContext),
951_this2._debugID,
952'componentDidUpdate');
953
954});
955}else{
956transaction.getReactMountReady().enqueue(
957inst.componentDidUpdate.bind(inst,prevProps,prevState,prevContext),
958inst);
959
960}
961}
962},
963
964
965
966
967
968
969
970_updateRenderedComponent:function _updateRenderedComponent(transaction,context){
971var prevComponentInstance=this._renderedComponent;
972var prevRenderedElement=prevComponentInstance._currentElement;
973var nextRenderedElement=this._renderValidatedComponent();
974
975var debugID=0;
976if(__DEV__){
977debugID=this._debugID;
978}
979
980if(shouldUpdateReactComponent(prevRenderedElement,nextRenderedElement)){
981ReactReconciler.receiveComponent(
982prevComponentInstance,
983nextRenderedElement,
984transaction,
985this._processChildContext(context));
986
987}else{
988var oldHostNode=ReactReconciler.getHostNode(prevComponentInstance);
989ReactReconciler.unmountComponent(prevComponentInstance,false);
990
991var nodeType=ReactNodeTypes.getType(nextRenderedElement);
992this._renderedNodeType=nodeType;
993var child=this._instantiateReactComponent(
994nextRenderedElement,
995nodeType!==ReactNodeTypes.EMPTY);
996
997this._renderedComponent=child;
998
999var nextMarkup=ReactReconciler.mountComponent(
1000child,
1001transaction,
1002this._hostParent,
1003this._hostContainerInfo,
1004this._processChildContext(context),
1005debugID);
1006
1007
1008if(__DEV__){
1009if(debugID!==0){
1010var childDebugIDs=child._debugID!==0?[child._debugID]:[];
1011ReactInstrumentation.debugTool.onSetChildren(debugID,childDebugIDs);
1012}
1013}
1014
1015this._replaceNodeWithMarkup(
1016oldHostNode,
1017nextMarkup,
1018prevComponentInstance);
1019
1020}
1021},
1022
1023
1024
1025
1026
1027
1028_replaceNodeWithMarkup:function _replaceNodeWithMarkup(oldHostNode,nextMarkup,prevInstance){
1029ReactComponentEnvironment.replaceNodeWithMarkup(
1030oldHostNode,
1031nextMarkup,
1032prevInstance);
1033
1034},
1035
1036
1037
1038
1039_renderValidatedComponentWithoutOwnerOrContext:function _renderValidatedComponentWithoutOwnerOrContext(){
1040var inst=this._instance;
1041var renderedElement;
1042
1043if(__DEV__){
1044renderedElement=measureLifeCyclePerf(
1045function(){return inst.render();},
1046this._debugID,
1047'render');
1048
1049}else{
1050renderedElement=inst.render();
1051}
1052
1053if(__DEV__){
1054
1055if(renderedElement===undefined&&
1056inst.render._isMockFunction){
1057
1058
1059renderedElement=null;
1060}
1061}
1062
1063return renderedElement;
1064},
1065
1066
1067
1068
1069_renderValidatedComponent:function _renderValidatedComponent(){
1070var renderedElement;
1071if(__DEV__||this._compositeType!==CompositeTypes.StatelessFunctional){
1072ReactCurrentOwner.current=this;
1073try{
1074renderedElement=
1075this._renderValidatedComponentWithoutOwnerOrContext();
1076}finally{
1077ReactCurrentOwner.current=null;
1078}
1079}else{
1080renderedElement=
1081this._renderValidatedComponentWithoutOwnerOrContext();
1082}
1083invariant(
1084
1085renderedElement===null||renderedElement===false||
1086React.isValidElement(renderedElement),
1087'%s.render(): A valid React element (or null) must be returned. You may have '+
1088'returned undefined, an array or some other invalid object.',
1089this.getName()||'ReactCompositeComponent');
1090
1091
1092return renderedElement;
1093},
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103attachRef:function attachRef(ref,component,transaction){
1104var inst=this.getPublicInstance();
1105invariant(inst!=null,'Stateless function components cannot have refs.');
1106var publicComponentInstance=component.getPublicInstance(transaction);
1107if(__DEV__){
1108var componentName=component&&component.getName?
1109component.getName():'a component';
1110warning(
1111publicComponentInstance!=null||
1112component._compositeType!==CompositeTypes.StatelessFunctional,
1113'Stateless function components cannot be given refs '+
1114'(See ref "%s" in %s created by %s). '+
1115'Attempts to access this ref will fail.',
1116ref,
1117componentName,
1118this.getName());
1119
1120}
1121var refs=inst.refs===emptyObject?inst.refs={}:inst.refs;
1122refs[ref]=publicComponentInstance;
1123},
1124
1125
1126
1127
1128
1129
1130
1131
1132detachRef:function detachRef(ref){
1133var refs=this.getPublicInstance().refs;
1134delete refs[ref];
1135},
1136
1137
1138
1139
1140
1141
1142
1143getName:function getName(){
1144var type=this._currentElement.type;
1145var constructor=this._instance&&this._instance.constructor;
1146return(
1147type.displayName||constructor&&constructor.displayName||
1148type.name||constructor&&constructor.name||
1149null);
1150
1151},
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161getPublicInstance:function getPublicInstance(){
1162var inst=this._instance;
1163if(this._compositeType===CompositeTypes.StatelessFunctional){
1164return null;
1165}
1166return inst;
1167},
1168
1169
1170_instantiateReactComponent:null};
1171
1172
1173
1174module.exports=ReactCompositeComponent;
Full Screen

d22e1cReactCompositeComponent.js

Source: d22e1cReactCompositeComponent.js Github

copy
1
2
3
4
5
6
7
8
9
10
11
12'use strict';
13
14var React=require('React');
15var ReactComponentEnvironment=require('ReactComponentEnvironment');
16var ReactCurrentOwner=require('react/lib/ReactCurrentOwner');
17var ReactErrorUtils=require('ReactErrorUtils');
18var ReactInstanceMap=require('ReactInstanceMap');
19var ReactInstrumentation=require('ReactInstrumentation');
20var ReactNodeTypes=require('ReactNodeTypes');
21var ReactReconciler=require('ReactReconciler');
22
23if(__DEV__){
24var checkReactTypeSpec=require('checkReactTypeSpec');
25}
26
27var emptyObject=require('fbjs/lib/emptyObject');
28var invariant=require('fbjs/lib/invariant');
29var shallowEqual=require('fbjs/lib/shallowEqual');
30var shouldUpdateReactComponent=require('shouldUpdateReactComponent');
31var warning=require('fbjs/lib/warning');
32
33
34
35var CompositeTypes={
36ImpureClass:0,
37PureClass:1,
38StatelessFunctional:2};
39
40
41function StatelessComponent(Component){
42}
43StatelessComponent.prototype.render=function(){
44var Component=ReactInstanceMap.get(this)._currentElement.type;
45var element=Component(this.props,this.context,this.updater);
46warnIfInvalidElement(Component,element);
47return element;
48};
49
50function warnIfInvalidElement(Component,element){
51if(__DEV__){
52warning(
53element===null||element===false||React.isValidElement(element),
54'%s(...): A valid React element (or null) must be returned. You may have '+
55'returned undefined, an array or some other invalid object.',
56Component.displayName||Component.name||'Component');
57
58warning(
59!Component.childContextTypes,
60'%s(...): childContextTypes cannot be defined on a functional component.',
61Component.displayName||Component.name||'Component');
62
63}
64}
65
66function shouldConstruct(Component){
67return!!(Component.prototype&&Component.prototype.isReactComponent);
68}
69
70function isPureComponent(Component){
71return!!(Component.prototype&&Component.prototype.isPureReactComponent);
72}
73
74
75function measureLifeCyclePerf(fn,debugID,timerType){
76if(debugID===0){
77
78
79
80return fn();
81}
82
83ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID,timerType);
84try{
85return fn();
86}finally{
87ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID,timerType);
88}
89}
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124var nextMountID=1;
125
126
127
128
129var ReactCompositeComponent={
130
131
132
133
134
135
136
137
138construct:function construct(element){
139this._currentElement=element;
140this._rootNodeID=0;
141this._compositeType=null;
142this._instance=null;
143this._hostParent=null;
144this._hostContainerInfo=null;
145
146
147this._updateBatchNumber=null;
148this._pendingElement=null;
149this._pendingStateQueue=null;
150this._pendingReplaceState=false;
151this._pendingForceUpdate=false;
152
153this._renderedNodeType=null;
154this._renderedComponent=null;
155this._context=null;
156this._mountOrder=0;
157this._topLevelWrapper=null;
158
159
160this._pendingCallbacks=null;
161
162
163this._calledComponentWillUnmount=false;
164
165if(__DEV__){
166this._warnedAboutRefsInRender=false;
167}
168},
169
170
171
172
173
174
175
176
177
178
179
180
181mountComponent:function mountComponent(
182transaction,
183hostParent,
184hostContainerInfo,
185context)
186{var _this=this;
187this._context=context;
188this._mountOrder=nextMountID++;
189this._hostParent=hostParent;
190this._hostContainerInfo=hostContainerInfo;
191
192var publicProps=this._currentElement.props;
193var publicContext=this._processContext(context);
194
195var Component=this._currentElement.type;
196
197var updateQueue=transaction.getUpdateQueue();
198
199
200var doConstruct=shouldConstruct(Component);
201var inst=this._constructComponent(
202doConstruct,
203publicProps,
204publicContext,
205updateQueue);
206
207var renderedElement;
208
209
210if(!doConstruct&&(inst==null||inst.render==null)){
211renderedElement=inst;
212warnIfInvalidElement(Component,renderedElement);
213invariant(
214inst===null||
215inst===false||
216React.isValidElement(inst),
217'%s(...): A valid React element (or null) must be returned. You may have '+
218'returned undefined, an array or some other invalid object.',
219Component.displayName||Component.name||'Component');
220
221inst=new StatelessComponent(Component);
222this._compositeType=CompositeTypes.StatelessFunctional;
223}else{
224if(isPureComponent(Component)){
225this._compositeType=CompositeTypes.PureClass;
226}else{
227this._compositeType=CompositeTypes.ImpureClass;
228}
229}
230
231if(__DEV__){
232
233
234if(inst.render==null){
235warning(
236false,
237'%s(...): No `render` method found on the returned component '+
238'instance: you may have forgotten to define `render`.',
239Component.displayName||Component.name||'Component');
240
241}
242
243var propsMutated=inst.props!==publicProps;
244var componentName=
245Component.displayName||Component.name||'Component';
246
247warning(
248inst.props===undefined||!propsMutated,
249'%s(...): When calling super() in `%s`, make sure to pass '+
250'up the same props that your component\'s constructor was passed.',
251componentName,componentName);
252
253}
254
255
256
257inst.props=publicProps;
258inst.context=publicContext;
259inst.refs=emptyObject;
260inst.updater=updateQueue;
261
262this._instance=inst;
263
264
265ReactInstanceMap.set(inst,this);
266
267if(__DEV__){
268
269
270
271warning(
272!inst.getInitialState||
273inst.getInitialState.isReactClassApproved,
274'getInitialState was defined on %s, a plain JavaScript class. '+
275'This is only supported for classes created using React.createClass. '+
276'Did you mean to define a state property instead?',
277this.getName()||'a component');
278
279warning(
280!inst.getDefaultProps||
281inst.getDefaultProps.isReactClassApproved,
282'getDefaultProps was defined on %s, a plain JavaScript class. '+
283'This is only supported for classes created using React.createClass. '+
284'Use a static property to define defaultProps instead.',
285this.getName()||'a component');
286
287warning(
288!inst.propTypes,
289'propTypes was defined as an instance property on %s. Use a static '+
290'property to define propTypes instead.',
291this.getName()||'a component');
292
293warning(
294!inst.contextTypes,
295'contextTypes was defined as an instance property on %s. Use a '+
296'static property to define contextTypes instead.',
297this.getName()||'a component');
298
299warning(
300typeof inst.componentShouldUpdate!=='function',
301'%s has a method called '+
302'componentShouldUpdate(). Did you mean shouldComponentUpdate()? '+
303'The name is phrased as a question because the function is '+
304'expected to return a value.',
305this.getName()||'A component');
306
307warning(
308typeof inst.componentDidUnmount!=='function',
309'%s has a method called '+
310'componentDidUnmount(). But there is no such lifecycle method. '+
311'Did you mean componentWillUnmount()?',
312this.getName()||'A component');
313
314warning(
315typeof inst.componentWillRecieveProps!=='function',
316'%s has a method called '+
317'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
318this.getName()||'A component');
319
320}
321
322var initialState=inst.state;
323if(initialState===undefined){
324inst.state=initialState=null;
325}
326invariant(
327typeof initialState==='object'&&!Array.isArray(initialState),
328'%s.state: must be set to an object or null',
329this.getName()||'ReactCompositeComponent');
330
331
332this._pendingStateQueue=null;
333this._pendingReplaceState=false;
334this._pendingForceUpdate=false;
335
336var markup;
337if(inst.unstable_handleError){
338markup=this.performInitialMountWithErrorHandling(
339renderedElement,
340hostParent,
341hostContainerInfo,
342transaction,
343context);
344
345}else{
346markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
347}
348
349if(inst.componentDidMount){
350if(__DEV__){
351transaction.getReactMountReady().enqueue(function(){
352measureLifeCyclePerf(
353function(){return inst.componentDidMount();},
354_this._debugID,
355'componentDidMount');
356
357});
358}else{
359transaction.getReactMountReady().enqueue(inst.componentDidMount,inst);
360}
361}
362
363return markup;
364},
365
366_constructComponent:function _constructComponent(
367doConstruct,
368publicProps,
369publicContext,
370updateQueue)
371{
372if(__DEV__){
373ReactCurrentOwner.current=this;
374try{
375return this._constructComponentWithoutOwner(
376doConstruct,
377publicProps,
378publicContext,
379updateQueue);
380
381}finally{
382ReactCurrentOwner.current=null;
383}
384}else{
385return this._constructComponentWithoutOwner(
386doConstruct,
387publicProps,
388publicContext,
389updateQueue);
390
391}
392},
393
394_constructComponentWithoutOwner:function _constructComponentWithoutOwner(
395doConstruct,
396publicProps,
397publicContext,
398updateQueue)
399{
400var Component=this._currentElement.type;
401
402if(doConstruct){
403if(__DEV__){
404return measureLifeCyclePerf(
405function(){return new Component(publicProps,publicContext,updateQueue);},
406this._debugID,
407'ctor');
408
409}else{
410return new Component(publicProps,publicContext,updateQueue);
411}
412}
413
414
415
416if(__DEV__){
417return measureLifeCyclePerf(
418function(){return Component(publicProps,publicContext,updateQueue);},
419this._debugID,
420'render');
421
422}else{
423return Component(publicProps,publicContext,updateQueue);
424}
425},
426
427performInitialMountWithErrorHandling:function performInitialMountWithErrorHandling(
428renderedElement,
429hostParent,
430hostContainerInfo,
431transaction,
432context)
433{
434var markup;
435var checkpoint=transaction.checkpoint();
436try{
437markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
438}catch(e){
439
440transaction.rollback(checkpoint);
441this._instance.unstable_handleError(e);
442if(this._pendingStateQueue){
443this._instance.state=this._processPendingState(this._instance.props,this._instance.context);
444}
445checkpoint=transaction.checkpoint();
446
447this._renderedComponent.unmountComponent(true);
448transaction.rollback(checkpoint);
449
450
451
452markup=this.performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context);
453}
454return markup;
455},
456
457performInitialMount:function performInitialMount(renderedElement,hostParent,hostContainerInfo,transaction,context){
458var inst=this._instance;
459
460var debugID=0;
461if(__DEV__){
462debugID=this._debugID;
463}
464
465if(inst.componentWillMount){
466if(__DEV__){
467measureLifeCyclePerf(
468function(){return inst.componentWillMount();},
469debugID,
470'componentWillMount');
471
472}else{
473inst.componentWillMount();
474}
475
476
477if(this._pendingStateQueue){
478inst.state=this._processPendingState(inst.props,inst.context);
479}
480}
481
482
483if(renderedElement===undefined){
484renderedElement=this._renderValidatedComponent();
485}
486
487var nodeType=ReactNodeTypes.getType(renderedElement);
488this._renderedNodeType=nodeType;
489var child=this._instantiateReactComponent(
490renderedElement,
491nodeType!==ReactNodeTypes.EMPTY);
492
493this._renderedComponent=child;
494
495var markup=ReactReconciler.mountComponent(
496child,
497transaction,
498hostParent,
499hostContainerInfo,
500this._processChildContext(context),
501debugID);
502
503
504if(__DEV__){
505if(debugID!==0){
506var childDebugIDs=child._debugID!==0?[child._debugID]:[];
507ReactInstrumentation.debugTool.onSetChildren(debugID,childDebugIDs);
508}
509}
510
511return markup;
512},
513
514getHostNode:function getHostNode(){
515return ReactReconciler.getHostNode(this._renderedComponent);
516},
517
518
519
520
521
522
523
524unmountComponent:function unmountComponent(safely){
525if(!this._renderedComponent){
526return;
527}
528
529var inst=this._instance;
530
531if(inst.componentWillUnmount&&!inst._calledComponentWillUnmount){
532inst._calledComponentWillUnmount=true;
533
534if(safely){
535var name=this.getName()+'.componentWillUnmount()';
536ReactErrorUtils.invokeGuardedCallback(name,inst.componentWillUnmount.bind(inst));
537}else{
538if(__DEV__){
539measureLifeCyclePerf(
540function(){return inst.componentWillUnmount();},
541this._debugID,
542'componentWillUnmount');
543
544}else{
545inst.componentWillUnmount();
546}
547}
548}
549
550if(this._renderedComponent){
551ReactReconciler.unmountComponent(this._renderedComponent,safely);
552this._renderedNodeType=null;
553this._renderedComponent=null;
554this._instance=null;
555}
556
557
558
559
560this._pendingStateQueue=null;
561this._pendingReplaceState=false;
562this._pendingForceUpdate=false;
563this._pendingCallbacks=null;
564this._pendingElement=null;
565
566
567
568this._context=null;
569this._rootNodeID=0;
570this._topLevelWrapper=null;
571
572
573
574
575ReactInstanceMap.remove(inst);
576
577
578
579
580
581
582},
583
584
585
586
587
588
589
590
591
592_maskContext:function _maskContext(context){
593var Component=this._currentElement.type;
594var contextTypes=Component.contextTypes;
595if(!contextTypes){
596return emptyObject;
597}
598var maskedContext={};
599for(var contextName in contextTypes){
600maskedContext[contextName]=context[contextName];
601}
602return maskedContext;
603},
604
605
606
607
608
609
610
611
612
613_processContext:function _processContext(context){
614var maskedContext=this._maskContext(context);
615if(__DEV__){
616var Component=this._currentElement.type;
617if(Component.contextTypes){
618this._checkContextTypes(
619Component.contextTypes,
620maskedContext,
621'context');
622
623}
624}
625return maskedContext;
626},
627
628
629
630
631
632
633_processChildContext:function _processChildContext(currentContext){
634var Component=this._currentElement.type;
635var inst=this._instance;
636var childContext;
637
638if(inst.getChildContext){
639if(__DEV__){
640ReactInstrumentation.debugTool.onBeginProcessingChildContext();
641try{
642childContext=inst.getChildContext();
643}finally{
644ReactInstrumentation.debugTool.onEndProcessingChildContext();
645}
646}else{
647childContext=inst.getChildContext();
648}
649}
650
651if(childContext){
652invariant(
653typeof Component.childContextTypes==='object',
654'%s.getChildContext(): childContextTypes must be defined in order to '+
655'use getChildContext().',
656this.getName()||'ReactCompositeComponent');
657
658if(__DEV__){
659this._checkContextTypes(
660Component.childContextTypes,
661childContext,
662'childContext');
663
664}
665for(var name in childContext){
666invariant(
667name in Component.childContextTypes,
668'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
669this.getName()||'ReactCompositeComponent',
670name);
671
672}
673return babelHelpers.extends({},currentContext,childContext);
674}
675return currentContext;
676},
677
678
679
680
681
682
683
684
685
686_checkContextTypes:function _checkContextTypes(
687typeSpecs,
688values,
689location)
690{
691if(__DEV__){
692checkReactTypeSpec(
693typeSpecs,
694values,
695location,
696this.getName(),
697null,
698this._debugID);
699
700}
701},
702
703receiveComponent:function receiveComponent(nextElement,transaction,nextContext){
704var prevElement=this._currentElement;
705var prevContext=this._context;
706
707this._pendingElement=null;
708
709this.updateComponent(
710transaction,
711prevElement,
712nextElement,
713prevContext,
714nextContext);
715
716},
717
718
719
720
721
722
723
724
725performUpdateIfNecessary:function performUpdateIfNecessary(transaction){
726if(this._pendingElement!=null){
727ReactReconciler.receiveComponent(
728this,
729this._pendingElement,
730transaction,
731this._context);
732
733}else if(this._pendingStateQueue!==null||this._pendingForceUpdate){
734this.updateComponent(
735transaction,
736this._currentElement,
737this._currentElement,
738this._context,
739this._context);
740
741}else{
742this._updateBatchNumber=null;
743}
744},
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761updateComponent:function updateComponent(
762transaction,
763prevParentElement,
764nextParentElement,
765prevUnmaskedContext,
766nextUnmaskedContext)
767{
768var inst=this._instance;
769invariant(
770inst!=null,
771'Attempted to update component `%s` that has already been unmounted '+
772'(or failed to mount).',
773this.getName()||'ReactCompositeComponent');
774
775
776var willReceive=false;
777var nextContext;
778
779
780if(this._context===nextUnmaskedContext){
781nextContext=inst.context;
782}else{
783nextContext=this._processContext(nextUnmaskedContext);
784willReceive=true;
785}
786
787var prevProps=prevParentElement.props;
788var nextProps=nextParentElement.props;
789
790
791if(prevParentElement!==nextParentElement){
792willReceive=true;
793}
794
795
796
797
798if(willReceive&&inst.componentWillReceiveProps){
799if(__DEV__){
800measureLifeCyclePerf(
801function(){return inst.componentWillReceiveProps(nextProps,nextContext);},
802this._debugID,
803'componentWillReceiveProps');
804
805}else{
806inst.componentWillReceiveProps(nextProps,nextContext);
807}
808}
809
810var nextState=this._processPendingState(nextProps,nextContext);
811var shouldUpdate=true;
812
813if(!this._pendingForceUpdate){
814if(inst.shouldComponentUpdate){
815if(__DEV__){
816shouldUpdate=measureLifeCyclePerf(
817function(){return inst.shouldComponentUpdate(nextProps,nextState,nextContext);},
818this._debugID,
819'shouldComponentUpdate');
820
821}else{
822shouldUpdate=inst.shouldComponentUpdate(nextProps,nextState,nextContext);
823}
824}else{
825if(this._compositeType===CompositeTypes.PureClass){
826shouldUpdate=
827!shallowEqual(prevProps,nextProps)||
828!shallowEqual(inst.state,nextState);
829}
830}
831}
832
833if(__DEV__){
834warning(
835shouldUpdate!==undefined,
836'%s.shouldComponentUpdate(): Returned undefined instead of a '+
837'boolean value. Make sure to return true or false.',
838this.getName()||'ReactCompositeComponent');
839
840}
841
842this._updateBatchNumber=null;
843if(shouldUpdate){
844this._pendingForceUpdate=false;
845
846this._performComponentUpdate(
847nextParentElement,
848nextProps,
849nextState,
850nextContext,
851transaction,
852nextUnmaskedContext);
853
854}else{
855
856
857this._currentElement=nextParentElement;
858this._context=nextUnmaskedContext;
859inst.props=nextProps;
860inst.state=nextState;
861inst.context=nextContext;
862}
863},
864
865_processPendingState:function _processPendingState(props,context){
866var inst=this._instance;
867var queue=this._pendingStateQueue;
868var replace=this._pendingReplaceState;
869this._pendingReplaceState=false;
870this._pendingStateQueue=null;
871
872if(!queue){
873return inst.state;
874}
875
876if(replace&&queue.length===1){
877return queue[0];
878}
879
880var nextState=babelHelpers.extends({},replace?queue[0]:inst.state);
881for(var i=replace?1:0;i<queue.length;i++){
882var partial=queue[i];
883babelHelpers.extends(
884nextState,
885typeof partial==='function'?
886partial.call(inst,nextState,props,context):
887partial);
888
889}
890
891return nextState;
892},
893
894
895
896
897
898
899
900
901
902
903
904
905
906_performComponentUpdate:function _performComponentUpdate(
907nextElement,
908nextProps,
909nextState,
910nextContext,
911transaction,
912unmaskedContext)
913{var _this2=this;
914var inst=this._instance;
915
916var hasComponentDidUpdate=Boolean(inst.componentDidUpdate);
917var prevProps;
918var prevState;
919var prevContext;
920if(hasComponentDidUpdate){
921prevProps=inst.props;
922prevState=inst.state;
923prevContext=inst.context;
924}
925
926if(inst.componentWillUpdate){
927if(__DEV__){
928measureLifeCyclePerf(
929function(){return inst.componentWillUpdate(nextProps,nextState,nextContext);},
930this._debugID,
931'componentWillUpdate');
932
933}else{
934inst.componentWillUpdate(nextProps,nextState,nextContext);
935}
936}
937
938this._currentElement=nextElement;
939this._context=unmaskedContext;
940inst.props=nextProps;
941inst.state=nextState;
942inst.context=nextContext;
943
944this._updateRenderedComponent(transaction,unmaskedContext);
945
946if(hasComponentDidUpdate){
947if(__DEV__){
948transaction.getReactMountReady().enqueue(function(){
949measureLifeCyclePerf(
950inst.componentDidUpdate.bind(inst,prevProps,prevState,prevContext),
951_this2._debugID,
952'componentDidUpdate');
953
954});
955}else{
956transaction.getReactMountReady().enqueue(
957inst.componentDidUpdate.bind(inst,prevProps,prevState,prevContext),
958inst);
959
960}
961}
962},
963
964
965
966
967
968
969
970_updateRenderedComponent:function _updateRenderedComponent(transaction,context){
971var prevComponentInstance=this._renderedComponent;
972var prevRenderedElement=prevComponentInstance._currentElement;
973var nextRenderedElement=this._renderValidatedComponent();
974
975var debugID=0;
976if(__DEV__){
977debugID=this._debugID;
978}