Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move component base classes into a single file #8918

Merged
merged 1 commit into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

'use strict';

var ReactBaseClasses = require('ReactBaseClasses');
var ReactChildren = require('ReactChildren');
var ReactComponent = require('ReactComponent');
var ReactPureComponent = require('ReactPureComponent');
var ReactClass = require('ReactClass');
var ReactDOMFactories = require('ReactDOMFactories');
var ReactElement = require('ReactElement');
Expand Down Expand Up @@ -78,8 +77,8 @@ var React = {
only: onlyChild,
},

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

createElement: createElement,
cloneElement: cloneElement,
Expand Down
4 changes: 3 additions & 1 deletion src/isomorphic/classic/class/ReactClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

'use strict';

var ReactComponent = require('ReactComponent');
var ReactBaseClasses = require('ReactBaseClasses');
var ReactElement = require('ReactElement');
var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
Expand All @@ -20,6 +20,8 @@ var emptyObject = require('emptyObject');
var invariant = require('invariant');
var warning = require('warning');

var ReactComponent = ReactBaseClasses.Component;

import type { ReactPropTypeLocations } from 'ReactPropTypeLocations';

var MIXINS_KEY = 'mixins';
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 @@ -126,4 +126,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.