Skip to content

Commit

Permalink
Change the behavior to always fail childContextTypes if there is a me…
Browse files Browse the repository at this point in the history
…thod (#8391)

Even if that method returns falsy values.
  • Loading branch information
sebmarkbage authored Nov 23, 2016
1 parent a3ba48b commit 7ef856a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions scripts/fiber/tests-passing-except-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/renderers/shared/fiber/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ describe('ReactCompositeComponent', () => {
return <div />;
}
}
Component.childContextTypes = {};

expectDev(console.error.calls.count()).toBe(0);
var instance = ReactDOM.render(<Component />, container);
Expand Down

0 comments on commit 7ef856a

Please sign in to comment.