@samitouri / QOS-React-2 / commits / 721fe73541

Removed setProps and replaceProps (both previously deprecated)

Jim committed Jul 2, 2015 at 03:45 UTC 721fe7354142c866db2ebcc727a2472a3f3e0cc6
16 files changed +45 -386
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
+3 -3
@@ -121,9 +121,9 @@ describe('ReactContextValidator', function() {
121 },
122 });
123
124 - var instance = <Parent foo="abc" />;
125 - instance = ReactTestUtils.renderIntoDocument(instance);
126 - instance.replaceProps({foo: 'def'});
124 + var container = document.createElement('div');
125 + React.render(<Parent foo="abc" />, container);
126 + React.render(<Parent foo="def" />, container);
127 expect(actualComponentWillReceiveProps).toEqual({foo: 'def'});
128 expect(actualShouldComponentUpdate).toEqual({foo: 'def'});
129 expect(actualComponentWillUpdate).toEqual({foo: 'def'});
src/isomorphic/classic/class/ReactClass.js
-32
@@ -728,38 +728,6 @@ var ReactClassMixin = {
728 isMounted: function() {
729 return this.updater.isMounted(this);
730 },
731 -
732 - /**
733 - * Sets a subset of the props.
734 - *
735 - * @param {object} partialProps Subset of the next props.
736 - * @param {?function} callback Called after props are updated.
737 - * @final
738 - * @public
739 - * @deprecated
740 - */
741 - setProps: function(partialProps, callback) {
742 - this.updater.enqueueSetProps(this, partialProps);
743 - if (callback) {
744 - this.updater.enqueueCallback(this, callback);
745 - }
746 - },
747 -
748 - /**
749 - * Replace all the props.
750 - *
751 - * @param {object} newProps Subset of the next props.
752 - * @param {?function} callback Called after props are updated.
753 - * @final
754 - * @public
755 - * @deprecated
756 - */
757 - replaceProps: function(newProps, callback) {
758 - this.updater.enqueueReplaceProps(this, newProps);
759 - if (callback) {
760 - this.updater.enqueueCallback(this, callback);
761 - }
762 - },
731 };
732
733 var ReactClassComponent = function() {};
src/isomorphic/modern/class/ReactComponent.js
-8
@@ -112,19 +112,11 @@ if (__DEV__) {
112 'Instead, make sure to clean up subscriptions and pending requests in ' +
113 'componentWillUnmount to prevent memory leaks.',
114 ],
115 - replaceProps: [
116 - 'replaceProps',
117 - 'Instead, call React.render again at the top level.',
118 - ],
115 replaceState: [
116 'replaceState',
117 'Refactor your code to use setState instead (see ' +
118 'https://github.com/facebook/react/issues/3236).',
119 ],
124 - setProps: [
125 - 'setProps',
126 - 'Instead, call React.render again at the top level.',
127 - ],
120 };
121 var defineDeprecationWarning = function(methodName, info) {
122 try {
src/isomorphic/modern/class/ReactNoopUpdateQueue.js
-23
@@ -98,29 +98,6 @@ var ReactNoopUpdateQueue = {
98 enqueueSetState: function(publicInstance, partialState) {
99 warnTDZ(publicInstance, 'setState');
100 },
101 -
102 - /**
103 - * Sets a subset of the props.
104 - *
105 - * @param {ReactClass} publicInstance The instance that should rerender.
106 - * @param {object} partialProps Subset of the next props.
107 - * @internal
108 - */
109 - enqueueSetProps: function(publicInstance, partialProps) {
110 - warnTDZ(publicInstance, 'setProps');
111 - },
112 -
113 - /**
114 - * Replaces all of the props.
115 - *
116 - * @param {ReactClass} publicInstance The instance that should rerender.
117 - * @param {object} props New props.
118 - * @internal
119 - */
120 - enqueueReplaceProps: function(publicInstance, props) {
121 - warnTDZ(publicInstance, 'replaceProps');
122 - },
123 -
101 };
102
103 module.exports = ReactNoopUpdateQueue;
src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee
+1 -9
@@ -346,9 +346,7 @@ describe 'ReactCoffeeScriptClass', ->
346 expect(-> instance.getDOMNode()).toThrow()
347 expect(-> instance.replaceState {}).toThrow()
348 expect(-> instance.isMounted()).toThrow()
349 - expect(-> instance.setProps name: 'bar').toThrow()
350 - expect(-> instance.replaceProps name: 'bar').toThrow()
351 - expect(console.error.calls.length).toBe 5
349 + expect(console.error.calls.length).toBe 3
350 expect(console.error.calls[0].args[0]).toContain(
351 'getDOMNode(...) is deprecated in plain JavaScript React classes'
352 )
@@ -358,12 +356,6 @@ describe 'ReactCoffeeScriptClass', ->
356 expect(console.error.calls[2].args[0]).toContain(
357 'isMounted(...) is deprecated in plain JavaScript React classes'
358 )
361 - expect(console.error.calls[3].args[0]).toContain(
362 - 'setProps(...) is deprecated in plain JavaScript React classes'
363 - )
364 - expect(console.error.calls[4].args[0]).toContain(
365 - 'replaceProps(...) is deprecated in plain JavaScript React classes'
366 - )
359
360 it 'supports this.context passed via getChildContext', ->
361 class Bar
src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+1 -9
@@ -404,9 +404,7 @@ describe('ReactES6Class', function() {
404 expect(() => instance.getDOMNode()).toThrow();
405 expect(() => instance.replaceState({})).toThrow();
406 expect(() => instance.isMounted()).toThrow();
407 - expect(() => instance.setProps({name: 'bar'})).toThrow();
408 - expect(() => instance.replaceProps({name: 'bar'})).toThrow();
409 - expect(console.error.calls.length).toBe(5);
407 + expect(console.error.calls.length).toBe(3);
408 expect(console.error.calls[0].args[0]).toContain(
409 'getDOMNode(...) is deprecated in plain JavaScript React classes. ' +
410 'Use React.findDOMNode(component) instead.'
@@ -417,12 +415,6 @@ describe('ReactES6Class', function() {
415 expect(console.error.calls[2].args[0]).toContain(
416 'isMounted(...) is deprecated in plain JavaScript React classes'
417 );
420 - expect(console.error.calls[3].args[0]).toContain(
421 - 'setProps(...) is deprecated in plain JavaScript React classes'
422 - );
423 - expect(console.error.calls[4].args[0]).toContain(
424 - 'replaceProps(...) is deprecated in plain JavaScript React classes'
425 - );
418 });
419
420 it('supports this.context passed via getChildContext', function() {
src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts
+1 -9
@@ -492,9 +492,7 @@ describe('ReactTypeScriptClass', function() {
492 expect(() => instance.getDOMNode()).toThrow();
493 expect(() => instance.replaceState({})).toThrow();
494 expect(() => instance.isMounted()).toThrow();
495 - expect(() => instance.setProps({ name: 'bar' })).toThrow();
496 - expect(() => instance.replaceProps({ name: 'bar' })).toThrow();
497 - expect((<any>console.error).argsForCall.length).toBe(5);
495 + expect((<any>console.error).argsForCall.length).toBe(3);
496 expect((<any>console.error).argsForCall[0][0]).toContain(
497 'getDOMNode(...) is deprecated in plain JavaScript React classes'
498 );
@@ -504,12 +502,6 @@ describe('ReactTypeScriptClass', function() {
502 expect((<any>console.error).argsForCall[2][0]).toContain(
503 'isMounted(...) is deprecated in plain JavaScript React classes'
504 );
507 - expect((<any>console.error).argsForCall[3][0]).toContain(
508 - 'setProps(...) is deprecated in plain JavaScript React classes'
509 - );
510 - expect((<any>console.error).argsForCall[4][0]).toContain(
511 - 'replaceProps(...) is deprecated in plain JavaScript React classes'
512 - );
505 });
506
507 it('supports this.context passed via getChildContext', function() {
src/renderers/dom/shared/ReactDOMComponent.js
-41
@@ -30,7 +30,6 @@ var ReactDOMTextarea = require('ReactDOMTextarea');
30 var ReactMount = require('ReactMount');
31 var ReactMultiChild = require('ReactMultiChild');
32 var ReactPerf = require('ReactPerf');
33 -var ReactUpdateQueue = require('ReactUpdateQueue');
33
34 var assign = require('Object.assign');
35 var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
@@ -130,44 +129,6 @@ function legacySetStateEtc() {
129 }
130 }
131
133 -function legacySetProps(partialProps, callback) {
134 - var component = this._reactInternalComponent;
135 - if (__DEV__) {
136 - warning(
137 - false,
138 - 'ReactDOMComponent: Do not access .setProps() of a DOM node. ' +
139 - 'Instead, call React.render again at the top level.%s',
140 - getDeclarationErrorAddendum(component)
141 - );
142 - }
143 - if (!component) {
144 - return;
145 - }
146 - ReactUpdateQueue.enqueueSetPropsInternal(component, partialProps);
147 - if (callback) {
148 - ReactUpdateQueue.enqueueCallbackInternal(component, callback);
149 - }
150 -}
151 -
152 -function legacyReplaceProps(partialProps, callback) {
153 - var component = this._reactInternalComponent;
154 - if (__DEV__) {
155 - warning(
156 - false,
157 - 'ReactDOMComponent: Do not access .replaceProps() of a DOM node. ' +
158 - 'Instead, call React.render again at the top level.%s',
159 - getDeclarationErrorAddendum(component)
160 - );
161 - }
162 - if (!component) {
163 - return;
164 - }
165 - ReactUpdateQueue.enqueueReplacePropsInternal(component, partialProps);
166 - if (callback) {
167 - ReactUpdateQueue.enqueueCallbackInternal(component, callback);
168 - }
169 -}
170 -
132 var styleMutationWarning = {};
133
134 function checkAndWarnForMutatedStyle(style1, style2, component) {
@@ -958,8 +919,6 @@ ReactDOMComponent.Mixin = {
919 node.setState = legacySetStateEtc;
920 node.replaceState = legacySetStateEtc;
921 node.forceUpdate = legacySetStateEtc;
961 - node.setProps = legacySetProps;
962 - node.replaceProps = legacyReplaceProps;
922
923 if (__DEV__) {
924 if (canDefineProperty) {
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
-23
@@ -974,29 +974,6 @@ describe('ReactDOMComponent', function() {
974 expect(console.error.calls[4].args[0]).toContain('isMounted');
975 });
976
977 - it('handles legacy setProps and replaceProps', function() {
978 - spyOn(console, 'error');
979 - var node = ReactTestUtils.renderIntoDocument(<div>rhinoceros</div>);
980 -
981 - node.setProps({className: 'herbiverous'});
982 - expect(node.className).toBe('herbiverous');
983 - expect(node.textContent).toBe('rhinoceros');
984 -
985 - node.replaceProps({className: 'invisible rhino'});
986 - expect(node.className).toBe('invisible rhino');
987 - expect(node.textContent).toBe('');
988 -
989 - expect(console.error.calls.length).toBe(2);
990 - expect(console.error.calls[0].args[0]).toBe(
991 - 'Warning: ReactDOMComponent: Do not access .setProps() of a DOM node. ' +
992 - 'Instead, call React.render again at the top level.'
993 - );
994 - expect(console.error.calls[1].args[0]).toBe(
995 - 'Warning: ReactDOMComponent: Do not access .replaceProps() of a DOM ' +
996 - 'node. Instead, call React.render again at the top level.'
997 - );
998 - });
999 -
977 it('does not touch ref-less nodes', function() {
978 var node = ReactTestUtils.renderIntoDocument(<div><span /></div>);
979 expect(typeof node.getDOMNode).toBe('function');
src/renderers/shared/reconciler/ReactUpdateQueue.js
+2 -89
@@ -12,11 +12,9 @@
12 'use strict';
13
14 var ReactCurrentOwner = require('ReactCurrentOwner');
15 -var ReactElement = require('ReactElement');
15 var ReactInstanceMap = require('ReactInstanceMap');
16 var ReactUpdates = require('ReactUpdates');
17
19 -var assign = require('Object.assign');
18 var invariant = require('invariant');
19 var warning = require('warning');
20
@@ -108,7 +106,7 @@ var ReactUpdateQueue = {
106 enqueueCallback: function(publicInstance, callback) {
107 invariant(
108 typeof callback === 'function',
111 - 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
109 + 'enqueueCallback(...): You called ' +
110 '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
111 'isn\'t callable.'
112 );
@@ -138,7 +136,7 @@ var ReactUpdateQueue = {
136 enqueueCallbackInternal: function(internalInstance, callback) {
137 invariant(
138 typeof callback === 'function',
141 - 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
139 + 'enqueueCallback(...): You called ' +
140 '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
141 'isn\'t callable.'
142 );
@@ -233,91 +231,6 @@ var ReactUpdateQueue = {
231 enqueueUpdate(internalInstance);
232 },
233
236 - /**
237 - * Sets a subset of the props.
238 - *
239 - * @param {ReactClass} publicInstance The instance that should rerender.
240 - * @param {object} partialProps Subset of the next props.
241 - * @internal
242 - */
243 - enqueueSetProps: function(publicInstance, partialProps) {
244 - var internalInstance = getInternalInstanceReadyForUpdate(
245 - publicInstance,
246 - 'setProps'
247 - );
248 - if (!internalInstance) {
249 - return;
250 - }
251 - ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
252 - },
253 -
254 - enqueueSetPropsInternal: function(internalInstance, partialProps) {
255 - var topLevelWrapper = internalInstance._topLevelWrapper;
256 - invariant(
257 - topLevelWrapper,
258 - 'setProps(...): You called `setProps` on a ' +
259 - 'component with a parent. This is an anti-pattern since props will ' +
260 - 'get reactively updated when rendered. Instead, change the owner\'s ' +
261 - '`render` method to pass the correct value as props to the component ' +
262 - 'where it is created.'
263 - );
264 -
265 - // Merge with the pending element if it exists, otherwise with existing
266 - // element props.
267 - var wrapElement = topLevelWrapper._pendingElement ||
268 - topLevelWrapper._currentElement;
269 - var element = wrapElement.props;
270 - var props = assign({}, element.props, partialProps);
271 - topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(
272 - wrapElement,
273 - ReactElement.cloneAndReplaceProps(element, props)
274 - );
275 -
276 - enqueueUpdate(topLevelWrapper);
277 - },
278 -
279 - /**
280 - * Replaces all of the props.
281 - *
282 - * @param {ReactClass} publicInstance The instance that should rerender.
283 - * @param {object} props New props.
284 - * @internal
285 - */
286 - enqueueReplaceProps: function(publicInstance, props) {
287 - var internalInstance = getInternalInstanceReadyForUpdate(
288 - publicInstance,
289 - 'replaceProps'
290 - );
291 - if (!internalInstance) {
292 - return;
293 - }
294 - ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
295 - },
296 -
297 - enqueueReplacePropsInternal: function(internalInstance, props) {
298 - var topLevelWrapper = internalInstance._topLevelWrapper;
299 - invariant(
300 - topLevelWrapper,
301 - 'replaceProps(...): You called `replaceProps` on a ' +
302 - 'component with a parent. This is an anti-pattern since props will ' +
303 - 'get reactively updated when rendered. Instead, change the owner\'s ' +
304 - '`render` method to pass the correct value as props to the component ' +
305 - 'where it is created.'
306 - );
307 -
308 - // Merge with the pending element if it exists, otherwise with existing
309 - // element props.
310 - var wrapElement = topLevelWrapper._pendingElement ||
311 - topLevelWrapper._currentElement;
312 - var element = wrapElement.props;
313 - topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(
314 - wrapElement,
315 - ReactElement.cloneAndReplaceProps(element, props)
316 - );
317 -
318 - enqueueUpdate(topLevelWrapper);
319 - },
320 -
234 enqueueElementInternal: function(internalInstance, newElement) {
235 internalInstance._pendingElement = newElement;
236 enqueueUpdate(internalInstance);
src/renderers/shared/reconciler/ReactUpdates.js
+1 -1
@@ -199,7 +199,7 @@ function enqueueUpdate(component) {
199 // Various parts of our code (such as ReactCompositeComponent's
200 // _renderValidatedComponent) assume that calls to render aren't nested;
201 // verify that that's the case. (This is called by each top-level update
202 - // function, like setProps, setState, forceUpdate, etc.; creation and
202 + // function, like setState, forceUpdate, etc.; creation and
203 // destruction of top-level components is guarded in ReactMount.)
204
205 if (!batchingStrategy.isBatchingUpdates) {
src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js
+10 -56
@@ -442,46 +442,6 @@ describe('ReactComponentLifeCycle', function() {
442 expect(instance.state).toEqual(POST_WILL_UNMOUNT_STATE);
443 });
444
445 - it('should throw when calling setProps() on an owned component', function() {
446 - /**
447 - * calls setProps in an componentDidMount.
448 - */
449 - var Inner = React.createClass({
450 - render: function() {
451 - return <div />;
452 - },
453 - });
454 - var PropsUpdaterInOnDOMReady = React.createClass({
455 - componentDidMount: function() {
456 - this.refs.theSimpleComponent.setProps({
457 - className: this.props.valueToUseInOnDOMReady,
458 - });
459 - },
460 - render: function() {
461 - return (
462 - <Inner
463 - className={this.props.valueToUseInitially}
464 - ref="theSimpleComponent"
465 - />
466 - );
467 - },
468 - });
469 - var instance =
470 - <PropsUpdaterInOnDOMReady
471 - valueToUseInitially="hello"
472 - valueToUseInOnDOMReady="goodbye"
473 - />;
474 - expect(function() {
475 - instance = ReactTestUtils.renderIntoDocument(instance);
476 - }).toThrow(
477 - 'Invariant Violation: setProps(...): You called `setProps` on a ' +
478 - 'component with a parent. This is an anti-pattern since props will get ' +
479 - 'reactively updated when rendered. Instead, change the owner\'s ' +
480 - '`render` method to pass the correct value as props to the component ' +
481 - 'where it is created.'
482 - );
483 - });
484 -
445 it('should not throw when updating an auxiliary component', function() {
446 var Tooltip = React.createClass({
447 render: function() {
@@ -512,24 +472,18 @@ describe('ReactComponentLifeCycle', function() {
472 },
473 });
474
515 - var instance = ReactTestUtils.renderIntoDocument(
516 - <Component text="uno" tooltipText="one" />
475 + var container = document.createElement('div');
476 + React.render(
477 + <Component text="uno" tooltipText="one" />,
478 + container
479 );
480
481 // Since `instance` is a root component, we can set its props. This also
482 // makes Tooltip rerender the tooltip component, which shouldn't throw.
521 - instance.setProps({text: 'dos', tooltipText: 'two'});
522 - });
523 -
524 - it('should not allow setProps() called on an unmounted element',
525 - function() {
526 - var PropsToUpdate = React.createClass({
527 - render: function() {
528 - return <div className={this.props.value} ref="theSimpleComponent" />;
529 - },
530 - });
531 - var instance = <PropsToUpdate value="hello" />;
532 - expect(instance.setProps).not.toBeDefined();
483 + React.render(
484 + <Component text="dos" tooltipText="two" />,
485 + container
486 + );
487 });
488
489 it('should allow state updates in componentDidMount', function() {
@@ -595,7 +549,7 @@ describe('ReactComponentLifeCycle', function() {
549
550 var container = document.createElement('div');
551 log = [];
598 - var instance = React.render(<Outer x={17} />, container);
552 + React.render(<Outer x={17} />, container);
553 expect(log).toEqual([
554 'outer componentWillMount',
555 'inner componentWillMount',
@@ -604,7 +558,7 @@ describe('ReactComponentLifeCycle', function() {
558 ]);
559
560 log = [];
607 - instance.setProps({x: 42});
561 + React.render(<Outer x={42} />, container);
562 expect(log).toEqual([
563 'outer componentWillReceiveProps',
564 'outer shouldComponentUpdate',
src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js
+3 -71
@@ -138,10 +138,7 @@ describe('ReactCompositeComponent', function() {
138 it('should not cache old DOM nodes when switching constructors', function() {
139 var instance = <ChildUpdates renderAnchor={true} anchorClassOn={false}/>;
140 instance = ReactTestUtils.renderIntoDocument(instance);
141 - instance.setProps({anchorClassOn: true}); // Warm any cache
142 - instance.setProps({renderAnchor: false}); // Clear out the anchor
141 // rerender
144 - instance.setProps({renderAnchor: true, anchorClassOn: false});
142 var anchor = instance.getAnchor();
143 var actualDOMAnchorNode = React.findDOMNode(anchor);
144 expect(actualDOMAnchorNode.className).toBe('');
@@ -399,72 +396,6 @@ describe('ReactCompositeComponent', function() {
396 expect(instance2.state.value).toBe(1);
397 });
398
402 - it('should not allow `setProps` on unmounted components', function() {
403 - var container = document.createElement('div');
404 - document.body.appendChild(container);
405 -
406 - var Component = React.createClass({
407 - render: function() {
408 - return <div />;
409 - },
410 - });
411 -
412 - var instance = <Component />;
413 - expect(instance.setProps).not.toBeDefined();
414 -
415 - instance = React.render(instance, container);
416 - expect(function() {
417 - instance.setProps({value: 1});
418 - }).not.toThrow();
419 - expect(console.error.calls.length).toBe(0);
420 -
421 - React.unmountComponentAtNode(container);
422 - expect(function() {
423 - instance.setProps({value: 2});
424 - }).not.toThrow();
425 -
426 - expect(console.error.calls.length).toBe(1);
427 - expect(console.error.argsForCall[0][0]).toBe(
428 - 'Warning: setProps(...): Can only update a mounted or ' +
429 - 'mounting component. This usually means you called setProps() on an ' +
430 - 'unmounted component. This is a no-op. Please check the code for the ' +
431 - 'Component component.'
432 - );
433 - });
434 -
435 - it('should only allow `setProps` on top-level components', function() {
436 - var container = document.createElement('div');
437 - document.body.appendChild(container);
438 -
439 - var innerInstance;
440 -
441 - var Inner = React.createClass({
442 - render: function() {
443 - return <div />;
444 - },
445 - });
446 - var Component = React.createClass({
447 - render: function() {
448 - return <div><Inner ref="inner" /></div>;
449 - },
450 - componentDidMount: function() {
451 - innerInstance = this.refs.inner;
452 - },
453 - });
454 - React.render(<Component />, container);
455 -
456 - expect(innerInstance).not.toBe(undefined);
457 - expect(function() {
458 - innerInstance.setProps({value: 1});
459 - }).toThrow(
460 - 'Invariant Violation: setProps(...): You called `setProps` on a ' +
461 - 'component with a parent. This is an anti-pattern since props will get ' +
462 - 'reactively updated when rendered. Instead, change the owner\'s ' +
463 - '`render` method to pass the correct value as props to the component ' +
464 - 'where it is created.'
465 - );
466 - });
467 -
399 it('should cleanup even if render() fatals', function() {
400 var BadComponent = React.createClass({
401 render: function() {
@@ -874,7 +805,8 @@ describe('ReactCompositeComponent', function() {
805 },
806 });
807
877 - var comp = ReactTestUtils.renderIntoDocument(<Component flipped={false} />);
808 + var container = document.createElement('div');
809 + var comp = React.render(<Component flipped={false} />, container);
810 expect(React.findDOMNode(comp.refs.static0).textContent).toBe('A');
811 expect(React.findDOMNode(comp.refs.static1).textContent).toBe('B');
812
@@ -885,7 +817,7 @@ describe('ReactCompositeComponent', function() {
817
818 // When flipping the order, the refs should update even though the actual
819 // contents do not
888 - comp.setProps({flipped: true});
820 + React.render(<Component flipped={true} />, container);
821 expect(React.findDOMNode(comp.refs.static0).textContent).toBe('B');
822 expect(React.findDOMNode(comp.refs.static1).textContent).toBe('A');
823
src/renderers/shared/reconciler/__tests__/ReactCompositeComponentState-test.js
+3 -2
@@ -138,8 +138,9 @@ describe('ReactCompositeComponent-state', function() {
138 this.peekAtState('initial-callback');
139 }
140 );
141 - instance.setProps(
142 - {nextColor: 'green'},
141 + React.render(
142 + <TestComponent stateListener={stateListener} nextColor="green" />,
143 + container,
144 instance.peekAtCallback('setProps')
145 );
146 instance.setFavoriteColor('blue');
src/renderers/shared/reconciler/__tests__/ReactMultiChildReconcile-test.js
+20 -8
@@ -15,7 +15,6 @@ require('mock-modules');
15
16 var React = require('React');
17 var ReactInstanceMap = require('ReactInstanceMap');
18 -var ReactTestUtils = require('ReactTestUtils');
18 var ReactMount = require('ReactMount');
19
20 var mapObject = require('mapObject');
@@ -212,15 +211,20 @@ function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
211 */
212 function testPropsSequence(sequence) {
213 var i;
215 - var parentInstance = ReactTestUtils.renderIntoDocument(
216 - <FriendsStatusDisplay {...sequence[0]} />
214 + var container = document.createElement('div');
215 + var parentInstance = React.render(
216 + <FriendsStatusDisplay {...sequence[0]} />,
217 + container
218 );
219 var statusDisplays = parentInstance.getStatusDisplays();
220 var lastInternalStates = getInteralStateByUserName(statusDisplays);
221 verifyStatuses(statusDisplays, sequence[0]);
222
223 for (i = 1; i < sequence.length; i++) {
223 - parentInstance.replaceProps(sequence[i]);
224 + React.render(
225 + <FriendsStatusDisplay {...sequence[i]} />,
226 + container
227 + );
228 statusDisplays = parentInstance.getStatusDisplays();
229 verifyStatuses(statusDisplays, sequence[i]);
230 verifyStatesPreserved(lastInternalStates, statusDisplays);
@@ -243,19 +247,27 @@ describe('ReactMultiChildReconcile', function() {
247 },
248 };
249
246 - var parentInstance = ReactTestUtils.renderIntoDocument(
247 - <FriendsStatusDisplay {...props} />
250 + var container = document.createElement('div');
251 + var parentInstance = React.render(
252 + <FriendsStatusDisplay {...props} />,
253 + container
254 );
255 var statusDisplays = parentInstance.getStatusDisplays();
256 var startingInternalState = statusDisplays.jcw.getInternalState();
257
258 // Now remove the child.
253 - parentInstance.replaceProps({usernameToStatus: {} });
259 + React.render(
260 + <FriendsStatusDisplay />,
261 + container
262 + );
263 statusDisplays = parentInstance.getStatusDisplays();
264 expect(statusDisplays.jcw).toBeFalsy();
265
266 // Now reset the props that cause there to be a child
258 - parentInstance.replaceProps(props);
267 + React.render(
268 + <FriendsStatusDisplay {...props} />,
269 + container
270 + );
271 statusDisplays = parentInstance.getStatusDisplays();
272 expect(statusDisplays.jcw).toBeTruthy();
273 expect(statusDisplays.jcw.getInternalState())
src/renderers/shared/reconciler/__tests__/ReactUpdates-test.js
-2
@@ -100,14 +100,12 @@ describe('ReactUpdates', function() {
100 expect(instance.state.y).toBe(0);
101
102 ReactUpdates.batchedUpdates(function() {
103 - instance.setProps({x: 1});
103 instance.setState({y: 2});
104 expect(instance.props.x).toBe(0);
105 expect(instance.state.y).toBe(0);
106 expect(updateCount).toBe(0);
107 });
108
110 - expect(instance.props.x).toBe(1);
109 expect(instance.state.y).toBe(2);
110 expect(updateCount).toBe(1);
111 });