Change the behavior to always fail childContextTypes if there is a method (#8391)
Even if that method returns falsy values.
Sebastian Markbåge committed
Nov 23, 2016 at 10:59 UTC
7ef856aa3676f898ac5014f77a3e176bdf727350
5 files changed
+6
-6
scripts/fiber/tests-failing.txt
-2
@@ -92,8 +92,6 @@ src/renderers/shared/stack/reconciler/__tests__/ReactComponentLifeCycle-test.js
92
* should carry through each of the phases of setup
93
94
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
95
-* should warn about `forceUpdate` on unmounted components
96
-* should warn about `setState` on unmounted components
95
* should warn about `setState` in render
96
* should warn about `setState` in getChildContext
97
* should update refs if shouldComponentUpdate gives false
scripts/fiber/tests-passing-except-dev.txt
+2
@@ -162,6 +162,8 @@ src/renderers/shared/stack/reconciler/__tests__/ReactComponentLifeCycle-test.js
162
* warns if findDOMNode is used inside render
163
164
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
165
+* should warn about `forceUpdate` on unmounted components
166
+* should warn about `setState` on unmounted components
167
* should disallow nested render calls
168
* should warn when mutated props are passed
169
src/renderers/shared/fiber/ReactFiberScheduler.js
+2
-1
@@ -760,7 +760,8 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
760
scheduleWorkAtPriority(root, priorityLevel);
761
return;
762
} else {
763
- throw new Error('Invalid root');
763
+ // TODO: Warn about setting state on an unmounted component.
764
+ return;
765
}
766
}
767
fiber = fiber.return;
src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
+1
-3
@@ -678,7 +678,7 @@ var ReactCompositeComponent = {
678
var inst = this._instance;
679
var childContext;
680
681
- if (inst.getChildContext) {
681
+ if (typeof inst.getChildContext === 'function') {
682
if (__DEV__) {
683
ReactInstrumentation.debugTool.onBeginProcessingChildContext();
684
try {
@@ -689,9 +689,7 @@ var ReactCompositeComponent = {
689
} else {
690
childContext = inst.getChildContext();
691
}
692
- }
692
694
- if (childContext) {
693
invariant(
694
typeof Component.childContextTypes === 'object',
695
'%s.getChildContext(): childContextTypes must be defined in order to ' +
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
+1
@@ -427,6 +427,7 @@ describe('ReactCompositeComponent', () => {
427
return <div />;
428
}
429
}
430
+ Component.childContextTypes = {};
431
432
expectDev(console.error.calls.count()).toBe(0);
433
var instance = ReactDOM.render(<Component />, container);