@samitouri / QOS-React-2 / commits / d914f15c0e

Revert "Overwriting of mutated props in constructor"

Sebastian Markbåge committed Oct 29, 2015 at 22:36 UTC d914f15c0e9f2aa9e229b2fcef45163402cfb13a
2 files changed +1 -36
src/renderers/shared/reconciler/ReactCompositeComponent.js
+1 -1
@@ -199,7 +199,7 @@ var ReactCompositeComponentMixin = {
199
200 // These should be set up in the constructor, but as a convenience for
201 // simpler class abstractions, we set them up after the fact.
202 - inst.props = inst.props || publicProps;
202 + inst.props = publicProps;
203 inst.context = publicContext;
204 inst.refs = emptyObject;
205 inst.updater = ReactUpdateQueue;
src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js
-35
@@ -1241,39 +1241,4 @@ describe('ReactCompositeComponent', function() {
1241
1242 });
1243
1244 - it('should not overwrite mutated properties', function() {
1245 - class Moo extends React.Component {
1246 - render() {
1247 - return <span />;
1248 - }
1249 - }
1250 - Moo.defaultProps = { idx: 'moo' };
1251 -
1252 - function Foo(props) {
1253 - var _props = { idx: this.constructor.defaultProps.idx + '?' };
1254 -
1255 - React.Component.call(this, _props);
1256 - }
1257 - Foo.prototype = Object.create(React.Component.prototype, {
1258 - constructor: {
1259 - value: Foo,
1260 - },
1261 - });
1262 - Foo.prototype.render = function() {
1263 - return <span />;
1264 - };
1265 - Foo.defaultProps = { idx: 'foo' };
1266 -
1267 - class Bar extends Foo {}
1268 - Bar.defaultProps = { idx: 'bar' };
1269 -
1270 - var moo = ReactTestUtils.renderIntoDocument(<Moo />);
1271 - expect(moo.props.idx).toBe('moo');
1272 -
1273 - var foo = ReactTestUtils.renderIntoDocument(<Foo />);
1274 - expect(foo.props.idx).toBe('foo?');
1275 -
1276 - var bar = ReactTestUtils.renderIntoDocument(<Bar />);
1277 - expect(bar.props.idx).toBe('bar?');
1278 - });
1244 });