Revert "Overwriting of mutated props in constructor"

This commit is contained in:
Sebastian Markbåge committed 2015-10-29 22:36:38 -07:00
1 parent 1384d43f53
commit d914f15c0e
2 files changed
+1 -36

No files matched your search

@@ -199,7 +199,7 @@ var ReactCompositeComponentMixin = {
// These should be set up in the constructor, but as a convenience for
// simpler class abstractions, we set them up after the fact.
inst.props = inst.props || publicProps;
inst.props = publicProps;
inst.context = publicContext;
inst.refs = emptyObject;
inst.updater = ReactUpdateQueue;
@@ -1241,39 +1241,4 @@ describe('ReactCompositeComponent', function() {
});
it('should not overwrite mutated properties', function() {
class Moo extends React.Component {
render() {
return <span />;
}
}
Moo.defaultProps = { idx: 'moo' };
function Foo(props) {
var _props = { idx: this.constructor.defaultProps.idx + '?' };
React.Component.call(this, _props);
}
Foo.prototype = Object.create(React.Component.prototype, {
constructor: {
value: Foo,
},
});
Foo.prototype.render = function() {
return <span />;
};
Foo.defaultProps = { idx: 'foo' };
class Bar extends Foo {}
Bar.defaultProps = { idx: 'bar' };
var moo = ReactTestUtils.renderIntoDocument(<Moo />);
expect(moo.props.idx).toBe('moo');
var foo = ReactTestUtils.renderIntoDocument(<Foo />);
expect(foo.props.idx).toBe('foo?');
var bar = ReactTestUtils.renderIntoDocument(<Bar />);
expect(bar.props.idx).toBe('bar?');
});
});