@samitouri / QOS-React / commits / 7e8068b984

Move component base classes into a single file (#8918)

Dan Abramov committed Feb 2, 2017 at 20:24 UTC 7e8068b9840dd98813787736385919683ddf2002
4 files changed +32 -47
src/isomorphic/React.js
+3 -4
@@ -11,9 +11,8 @@
11
12 'use strict';
13
14 +var ReactBaseClasses = require('ReactBaseClasses');
15 var ReactChildren = require('ReactChildren');
15 -var ReactComponent = require('ReactComponent');
16 -var ReactPureComponent = require('ReactPureComponent');
16 var ReactClass = require('ReactClass');
17 var ReactDOMFactories = require('ReactDOMFactories');
18 var ReactElement = require('ReactElement');
@@ -78,8 +77,8 @@ var React = {
77 only: onlyChild,
78 },
79
81 - Component: ReactComponent,
82 - PureComponent: ReactPureComponent,
80 + Component: ReactBaseClasses.Component,
81 + PureComponent: ReactBaseClasses.PureComponent,
82
83 createElement: createElement,
84 cloneElement: cloneElement,
src/isomorphic/classic/class/ReactClass.js
+3 -1
@@ -11,7 +11,7 @@
11
12 'use strict';
13
14 -var ReactComponent = require('ReactComponent');
14 +var ReactBaseClasses = require('ReactBaseClasses');
15 var ReactElement = require('ReactElement');
16 var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
17 var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
@@ -20,6 +20,8 @@ var emptyObject = require('emptyObject');
20 var invariant = require('invariant');
21 var warning = require('warning');
22
23 +var ReactComponent = ReactBaseClasses.Component;
24 +
25 import type { ReactPropTypeLocations } from 'ReactPropTypeLocations';
26
27 var MIXINS_KEY = 'mixins';
src/isomorphic/modern/class/ReactBaseClasses.js renamed
+26 -2
@@ -6,7 +6,7 @@
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
8 *
9 - * @providesModule ReactComponent
9 + * @providesModule ReactBaseClasses
10 */
11
12 'use strict';
@@ -126,4 +126,28 @@ if (__DEV__) {
126 }
127 }
128
129 -module.exports = ReactComponent;
129 +/**
130 + * Base class helpers for the updating state of a component.
131 + */
132 +function ReactPureComponent(props, context, updater) {
133 + // Duplicated from ReactComponent.
134 + this.props = props;
135 + this.context = context;
136 + this.refs = emptyObject;
137 + // We initialize the default updater but the real one gets injected by the
138 + // renderer.
139 + this.updater = updater || ReactNoopUpdateQueue;
140 +}
141 +
142 +function ComponentDummy() {}
143 +ComponentDummy.prototype = ReactComponent.prototype;
144 +ReactPureComponent.prototype = new ComponentDummy();
145 +ReactPureComponent.prototype.constructor = ReactPureComponent;
146 +// Avoid an extra prototype jump for these methods.
147 +Object.assign(ReactPureComponent.prototype, ReactComponent.prototype);
148 +ReactPureComponent.prototype.isPureReactComponent = true;
149 +
150 +module.exports = {
151 + Component: ReactComponent,
152 + PureComponent: ReactPureComponent,
153 +};
src/isomorphic/modern/class/ReactPureComponent.js deleted
-40
@@ -1,40 +0,0 @@
1 -/**
2 - * Copyright 2013-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule ReactPureComponent
10 - */
11 -
12 -'use strict';
13 -
14 -var ReactComponent = require('ReactComponent');
15 -var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
16 -
17 -var emptyObject = require('emptyObject');
18 -
19 -/**
20 - * Base class helpers for the updating state of a component.
21 - */
22 -function ReactPureComponent(props, context, updater) {
23 - // Duplicated from ReactComponent.
24 - this.props = props;
25 - this.context = context;
26 - this.refs = emptyObject;
27 - // We initialize the default updater but the real one gets injected by the
28 - // renderer.
29 - this.updater = updater || ReactNoopUpdateQueue;
30 -}
31 -
32 -function ComponentDummy() {}
33 -ComponentDummy.prototype = ReactComponent.prototype;
34 -ReactPureComponent.prototype = new ComponentDummy();
35 -ReactPureComponent.prototype.constructor = ReactPureComponent;
36 -// Avoid an extra prototype jump for these methods.
37 -Object.assign(ReactPureComponent.prototype, ReactComponent.prototype);
38 -ReactPureComponent.prototype.isPureReactComponent = true;
39 -
40 -module.exports = ReactPureComponent;