mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Stop passing prevContext param to componentDidUpdate (#8631)
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
|
||||
* should pass previous context to lifecycles
|
||||
|
||||
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
|
||||
* gives source code refs for unknown prop warning (ssr)
|
||||
* gives source code refs for unknown prop warning for exact elements (ssr)
|
||||
|
||||
@@ -89,6 +89,7 @@ src/isomorphic/children/__tests__/onlyChild-test.js
|
||||
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
|
||||
* should filter out context not in contextTypes
|
||||
* should pass next context to lifecycles
|
||||
* should not pass previous context to lifecycles
|
||||
* should check context types
|
||||
* should check child context types
|
||||
* should warn (but not error) if getChildContext method is missing
|
||||
|
||||
@@ -125,14 +125,13 @@ describe('ReactContextValidator', () => {
|
||||
expect(actualComponentWillUpdate).toEqual({foo: 'def'});
|
||||
});
|
||||
|
||||
it('should pass previous context to lifecycles', () => {
|
||||
it('should not pass previous context to lifecycles', () => {
|
||||
var actualComponentDidUpdate;
|
||||
|
||||
class Parent extends React.Component {
|
||||
getChildContext() {
|
||||
return {
|
||||
foo: this.props.foo,
|
||||
bar: 'bar',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -142,12 +141,11 @@ describe('ReactContextValidator', () => {
|
||||
}
|
||||
Parent.childContextTypes = {
|
||||
foo: PropTypes.string.isRequired,
|
||||
bar: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
class Component extends React.Component {
|
||||
componentDidUpdate(prevProps, prevState, prevContext) {
|
||||
actualComponentDidUpdate = prevContext;
|
||||
componentDidUpdate(...args) {
|
||||
actualComponentDidUpdate = args;
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -161,7 +159,7 @@ describe('ReactContextValidator', () => {
|
||||
var container = document.createElement('div');
|
||||
ReactDOM.render(<Parent foo="abc" />, container);
|
||||
ReactDOM.render(<Parent foo="def" />, container);
|
||||
expect(actualComponentDidUpdate).toEqual({foo: 'abc'});
|
||||
expect(actualComponentDidUpdate).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should check context types', () => {
|
||||
|
||||
@@ -15,7 +15,6 @@ var ChildUpdates;
|
||||
var MorphingComponent;
|
||||
var React;
|
||||
var ReactDOM;
|
||||
var ReactDOMFeatureFlags;
|
||||
var ReactDOMServer;
|
||||
var ReactCurrentOwner;
|
||||
var ReactPropTypes;
|
||||
@@ -28,7 +27,6 @@ describe('ReactCompositeComponent', () => {
|
||||
jest.resetModules();
|
||||
React = require('react');
|
||||
ReactDOM = require('react-dom');
|
||||
ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
ReactDOMServer = require('react-dom/server');
|
||||
ReactCurrentOwner = require('ReactCurrentOwner');
|
||||
ReactPropTypes = require('ReactPropTypes');
|
||||
@@ -806,13 +804,6 @@ describe('ReactCompositeComponent', () => {
|
||||
expect('foo' in nextContext).toBe(true);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState, prevContext) {
|
||||
if (!ReactDOMFeatureFlags.useFiber) {
|
||||
// Fiber does not pass the previous context.
|
||||
expect('foo' in prevContext).toBe(true);
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState, nextContext) {
|
||||
expect('foo' in nextContext).toBe(true);
|
||||
return true;
|
||||
@@ -828,13 +819,6 @@ describe('ReactCompositeComponent', () => {
|
||||
expect('foo' in nextContext).toBe(false);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState, prevContext) {
|
||||
if (!ReactDOMFeatureFlags.useFiber) {
|
||||
// Fiber does not pass the previous context.
|
||||
expect('foo' in prevContext).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState, nextContext) {
|
||||
expect('foo' in nextContext).toBe(false);
|
||||
return true;
|
||||
|
||||
@@ -1022,11 +1022,9 @@ var ReactCompositeComponent = {
|
||||
var hasComponentDidUpdate = !!inst.componentDidUpdate;
|
||||
var prevProps;
|
||||
var prevState;
|
||||
var prevContext;
|
||||
if (hasComponentDidUpdate) {
|
||||
prevProps = inst.props;
|
||||
prevState = inst.state;
|
||||
prevContext = inst.context;
|
||||
}
|
||||
|
||||
if (inst.componentWillUpdate) {
|
||||
@@ -1060,12 +1058,7 @@ var ReactCompositeComponent = {
|
||||
if (__DEV__) {
|
||||
transaction.getReactMountReady().enqueue(() => {
|
||||
measureLifeCyclePerf(
|
||||
inst.componentDidUpdate.bind(
|
||||
inst,
|
||||
prevProps,
|
||||
prevState,
|
||||
prevContext,
|
||||
),
|
||||
inst.componentDidUpdate.bind(inst, prevProps, prevState),
|
||||
this._debugID,
|
||||
'componentDidUpdate',
|
||||
);
|
||||
@@ -1074,12 +1067,7 @@ var ReactCompositeComponent = {
|
||||
transaction
|
||||
.getReactMountReady()
|
||||
.enqueue(
|
||||
inst.componentDidUpdate.bind(
|
||||
inst,
|
||||
prevProps,
|
||||
prevState,
|
||||
prevContext,
|
||||
),
|
||||
inst.componentDidUpdate.bind(inst, prevProps, prevState),
|
||||
inst,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user