Introducing ReactComponentBase base class

This is the base class that will be used by ES6 classes.

I'm only moving setState and forceUpdate to this base class and the other
functions are disabled for modern classes as we're intending to deprecate
them. The base classes only have getters that warn if accessed. It's as if
they didn't exist.

ReactClass now extends ReactComponentBase but also adds the deprecated
methods. They are not yet fully deprecated on the ReactClass API.

I added some extra tests to composite component which we weren't testing
to avoid regressions.

I also added some test for ES6 classes. These are not testing the new
state initialization process. That's coming in a follow up.
This commit is contained in:
Sebastian Markbage
2015-01-13 10:54:19 -08:00
parent 90053da7bd
commit ff032dc857
5 changed files with 363 additions and 68 deletions
+2
View File
@@ -17,6 +17,7 @@ var DOMPropertyOperations = require('DOMPropertyOperations');
var EventPluginUtils = require('EventPluginUtils');
var ReactChildren = require('ReactChildren');
var ReactComponent = require('ReactComponent');
var ReactComponentBase = require('ReactComponentBase');
var ReactClass = require('ReactClass');
var ReactContext = require('ReactContext');
var ReactCurrentOwner = require('ReactCurrentOwner');
@@ -57,6 +58,7 @@ var React = {
count: ReactChildren.count,
only: onlyChild
},
Component: ReactComponentBase,
DOM: ReactDOM,
PropTypes: ReactPropTypes,
initializeTouchEvents: function(shouldUseTouch) {