|
6 | 6 | * LICENSE file in the root directory of this source tree. An additional grant |
7 | 7 | * of patent rights can be found in the PATENTS file in the same directory. |
8 | 8 | * |
9 | | - * @providesModule ReactComponent |
| 9 | + * @providesModule ReactBaseClasses |
10 | 10 | */ |
11 | 11 |
|
12 | 12 | 'use strict'; |
@@ -132,4 +132,28 @@ if (__DEV__) { |
132 | 132 | } |
133 | 133 | } |
134 | 134 |
|
135 | | -module.exports = ReactComponent; |
| 135 | +/** |
| 136 | + * Base class helpers for the updating state of a component. |
| 137 | + */ |
| 138 | +function ReactPureComponent(props, context, updater) { |
| 139 | + // Duplicated from ReactComponent. |
| 140 | + this.props = props; |
| 141 | + this.context = context; |
| 142 | + this.refs = emptyObject; |
| 143 | + // We initialize the default updater but the real one gets injected by the |
| 144 | + // renderer. |
| 145 | + this.updater = updater || ReactNoopUpdateQueue; |
| 146 | +} |
| 147 | + |
| 148 | +function ComponentDummy() {} |
| 149 | +ComponentDummy.prototype = ReactComponent.prototype; |
| 150 | +ReactPureComponent.prototype = new ComponentDummy(); |
| 151 | +ReactPureComponent.prototype.constructor = ReactPureComponent; |
| 152 | +// Avoid an extra prototype jump for these methods. |
| 153 | +Object.assign(ReactPureComponent.prototype, ReactComponent.prototype); |
| 154 | +ReactPureComponent.prototype.isPureReactComponent = true; |
| 155 | + |
| 156 | +module.exports = { |
| 157 | + Component: ReactComponent, |
| 158 | + PureComponent: ReactPureComponent, |
| 159 | +}; |
0 commit comments