The library for web and native user interfaces.
[React] Removing invariant warning about updating owner state
It seems like it's possible to render a component that ends up having an owner. Because you can end up rendering inside a render somehow.
CommitSyncScript committed
Jun 4, 2013 at 12:16 UTC
3e211bf662d0b8f67bbdea32566dae75a8c73485
2 files changed
-36
src/core/ReactComponent.js
-8
@@ -235,14 +235,6 @@ var ReactComponent = {
235
* @public
236
*/
237
replaceProps: function(props) {
238
- invariant(
239
- !this.props[OWNER],
240
- 'replaceProps(...): You called `setProps` or `replaceProps` on a ' +
241
- 'component with an owner. This is an anti-pattern since props will ' +
242
- 'get reactively updated when rendered. Instead, change the owner\'s ' +
243
- '`render` method to pass the correct value as props to the component ' +
244
- 'where it is created.'
245
- );
238
var transaction = ReactComponent.ReactReconcileTransaction.getPooled();
239
transaction.perform(this.receiveProps, this, props, transaction);
240
ReactComponent.ReactReconcileTransaction.release(transaction);
src/core/__tests__/ReactComponentLifeCycle-test.js
-28
@@ -375,34 +375,6 @@ describe('ReactComponentLifeCycle', function() {
375
expect(instance.state).toEqual(POST_WILL_UNMOUNT_STATE);
376
});
377
378
- it('should throw when calling setProps() on an owned component', function() {
379
- /**
380
- * calls setProps in an componentDidMount.
381
- */
382
- var PropsUpdaterInOnDOMReady = React.createClass({
383
- componentDidMount: function() {
384
- this.refs.theSimpleComponent.setProps({
385
- value: this.props.valueToUseInOnDOMReady
386
- });
387
- },
388
- render: function() {
389
- return (
390
- <input
391
- value={this.props.valueToUseInitially}
392
- ref="theSimpleComponent">
393
- </input>
394
- );
395
- }
396
- });
397
- var instance =
398
- <PropsUpdaterInOnDOMReady
399
- valueToUseInitially="hello"
400
- valueToUseInOnDOMReady="goodbye"
401
- />;
402
- expect(ReactTestUtils.renderIntoDocument.bind(ReactTestUtils, instance))
403
- .toThrow();
404
- });
405
-
378
it('should allow state updates in componentDidMount', function() {
379
/**
380
* calls setState in an componentDidMount.