mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #3999 from jimfb/more-context-cleanup
Removed ReactContext (cleanup)
This commit is contained in:
@@ -216,20 +216,16 @@ describe('ReactContextValidator', function() {
|
||||
});
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component testContext={{bar: 123}} />);
|
||||
expect(console.error.argsForCall.length).toBe(2);
|
||||
expect(console.error.argsForCall.length).toBe(1);
|
||||
expect(console.error.argsForCall[0][0]).toBe(
|
||||
'Warning: Failed Context Types: ' +
|
||||
'Required child context `foo` was not specified in `Component`.'
|
||||
);
|
||||
expect(console.error.argsForCall[1][0]).toBe(
|
||||
'Warning: Failed Context Types: ' +
|
||||
'Required child context `foo` was not specified in `Component`.'
|
||||
);
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<Component testContext={{foo: 123}} />);
|
||||
|
||||
expect(console.error.argsForCall.length).toBe(4);
|
||||
expect(console.error.argsForCall[3][0]).toBe(
|
||||
expect(console.error.argsForCall.length).toBe(2);
|
||||
expect(console.error.argsForCall[1][0]).toBe(
|
||||
'Warning: Failed Context Types: ' +
|
||||
'Invalid child context `foo` of type `number` ' +
|
||||
'supplied to `Component`, expected `string`.'
|
||||
@@ -244,7 +240,7 @@ describe('ReactContextValidator', function() {
|
||||
);
|
||||
|
||||
// Previous calls should not log errors
|
||||
expect(console.error.argsForCall.length).toBe(4);
|
||||
expect(console.error.argsForCall.length).toBe(2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
'use strict';
|
||||
|
||||
var ReactComponentEnvironment = require('ReactComponentEnvironment');
|
||||
var ReactContext = require('ReactContext');
|
||||
var ReactCurrentOwner = require('ReactCurrentOwner');
|
||||
var ReactElement = require('ReactElement');
|
||||
var ReactElementValidator = require('ReactElementValidator');
|
||||
@@ -756,16 +755,11 @@ var ReactCompositeComponentMixin = {
|
||||
*/
|
||||
_renderValidatedComponent: function() {
|
||||
var renderedComponent;
|
||||
var previousContext = ReactContext.current;
|
||||
ReactContext.current = this._processChildContext(
|
||||
this._currentElement._context
|
||||
);
|
||||
ReactCurrentOwner.current = this;
|
||||
try {
|
||||
renderedComponent =
|
||||
this._renderValidatedComponentWithoutOwnerOrContext();
|
||||
} finally {
|
||||
ReactContext.current = previousContext;
|
||||
ReactCurrentOwner.current = null;
|
||||
}
|
||||
invariant(
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* 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 ReactContext
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var emptyObject = require('emptyObject');
|
||||
|
||||
/**
|
||||
* Keeps track of the current context.
|
||||
*
|
||||
* The context is automatically passed down the component ownership hierarchy
|
||||
* and is accessible via `this.context` on ReactCompositeComponents.
|
||||
*/
|
||||
var ReactContext = {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @type {object}
|
||||
*/
|
||||
current: emptyObject
|
||||
|
||||
};
|
||||
|
||||
module.exports = ReactContext;
|
||||
Reference in New Issue
Block a user