Skip to content

Commit

Permalink
Move component base classes into a single file (facebook#8918)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and flarnie committed May 25, 2017
1 parent 68d3370 commit 3d1062b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 44 deletions.
5 changes: 3 additions & 2 deletions src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

'use strict';

var ReactBaseClasses = require('ReactBaseClasses');
var ReactChildren = require('ReactChildren');
var ReactComponent = require('ReactComponent');
var ReactPureComponent = require('ReactPureComponent');
Expand Down Expand Up @@ -81,8 +82,8 @@ var React = {
only: onlyChild,
},

Component: ReactComponent,
PureComponent: ReactPureComponent,
Component: ReactBaseClasses.Component,
PureComponent: ReactBaseClasses.PureComponent,

createElement: createElement,
cloneElement: cloneElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactComponent
* @providesModule ReactBaseClasses
*/

'use strict';
Expand Down Expand Up @@ -132,4 +132,28 @@ if (__DEV__) {
}
}

module.exports = ReactComponent;
/**
* Base class helpers for the updating state of a component.
*/
function ReactPureComponent(props, context, updater) {
// Duplicated from ReactComponent.
this.props = props;
this.context = context;
this.refs = emptyObject;
// We initialize the default updater but the real one gets injected by the
// renderer.
this.updater = updater || ReactNoopUpdateQueue;
}

function ComponentDummy() {}
ComponentDummy.prototype = ReactComponent.prototype;
ReactPureComponent.prototype = new ComponentDummy();
ReactPureComponent.prototype.constructor = ReactPureComponent;
// Avoid an extra prototype jump for these methods.
Object.assign(ReactPureComponent.prototype, ReactComponent.prototype);
ReactPureComponent.prototype.isPureReactComponent = true;

module.exports = {
Component: ReactComponent,
PureComponent: ReactPureComponent,
};
40 changes: 0 additions & 40 deletions src/isomorphic/modern/class/ReactPureComponent.js

This file was deleted.

0 comments on commit 3d1062b

Please sign in to comment.