mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Change the behavior to always fail childContextTypes if there is a method (#8391)
Even if that method returns falsy values.
This commit is contained in:
committed by
GitHub
parent
a3ba48bf72
commit
7ef856aa36
@@ -92,8 +92,6 @@ src/renderers/shared/stack/reconciler/__tests__/ReactComponentLifeCycle-test.js
|
||||
* should carry through each of the phases of setup
|
||||
|
||||
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
|
||||
* should warn about `forceUpdate` on unmounted components
|
||||
* should warn about `setState` on unmounted components
|
||||
* should warn about `setState` in render
|
||||
* should warn about `setState` in getChildContext
|
||||
* should update refs if shouldComponentUpdate gives false
|
||||
|
||||
@@ -162,6 +162,8 @@ src/renderers/shared/stack/reconciler/__tests__/ReactComponentLifeCycle-test.js
|
||||
* warns if findDOMNode is used inside render
|
||||
|
||||
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
|
||||
* should warn about `forceUpdate` on unmounted components
|
||||
* should warn about `setState` on unmounted components
|
||||
* should disallow nested render calls
|
||||
* should warn when mutated props are passed
|
||||
|
||||
|
||||
@@ -760,7 +760,8 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
||||
scheduleWorkAtPriority(root, priorityLevel);
|
||||
return;
|
||||
} else {
|
||||
throw new Error('Invalid root');
|
||||
// TODO: Warn about setting state on an unmounted component.
|
||||
return;
|
||||
}
|
||||
}
|
||||
fiber = fiber.return;
|
||||
|
||||
@@ -678,7 +678,7 @@ var ReactCompositeComponent = {
|
||||
var inst = this._instance;
|
||||
var childContext;
|
||||
|
||||
if (inst.getChildContext) {
|
||||
if (typeof inst.getChildContext === 'function') {
|
||||
if (__DEV__) {
|
||||
ReactInstrumentation.debugTool.onBeginProcessingChildContext();
|
||||
try {
|
||||
@@ -689,9 +689,7 @@ var ReactCompositeComponent = {
|
||||
} else {
|
||||
childContext = inst.getChildContext();
|
||||
}
|
||||
}
|
||||
|
||||
if (childContext) {
|
||||
invariant(
|
||||
typeof Component.childContextTypes === 'object',
|
||||
'%s.getChildContext(): childContextTypes must be defined in order to ' +
|
||||
|
||||
@@ -427,6 +427,7 @@ describe('ReactCompositeComponent', () => {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
Component.childContextTypes = {};
|
||||
|
||||
expectDev(console.error.calls.count()).toBe(0);
|
||||
var instance = ReactDOM.render(<Component />, container);
|
||||
|
||||
Reference in New Issue
Block a user