diff --git a/scripts/fiber/tests-failing.txt b/scripts/fiber/tests-failing.txt index 385e8aa90418..a41b7230a1ec 100644 --- a/scripts/fiber/tests-failing.txt +++ b/scripts/fiber/tests-failing.txt @@ -526,7 +526,6 @@ src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js * should warn about `setState` on unmounted components * should warn about `setState` in render * should warn about `setState` in getChildContext -* should warn when shouldComponentUpdate() returns undefined * should pass context to children when not owner * should pass context when re-rendered for static child * should pass context when re-rendered for static child within a composite component diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index bf71b6329a57..b554584d0163 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -1016,6 +1016,7 @@ src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js * should silently allow `setState`, not call cb on unmounting components * should cleanup even if render() fatals * should call componentWillUnmount before unmounting +* should warn when shouldComponentUpdate() returns undefined * should warn when componentDidUnmount method is defined * should skip update when rerendering element in container * only renders once if updated in componentWillReceiveProps diff --git a/src/renderers/shared/fiber/ReactFiberClassComponent.js b/src/renderers/shared/fiber/ReactFiberClassComponent.js index 5d9be3005e34..fb8a0352fa2c 100644 --- a/src/renderers/shared/fiber/ReactFiberClassComponent.js +++ b/src/renderers/shared/fiber/ReactFiberClassComponent.js @@ -82,7 +82,18 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) { const instance = workInProgress.stateNode; if (typeof instance.shouldComponentUpdate === 'function') { - return instance.shouldComponentUpdate(newProps, newState); + const shouldUpdate = instance.shouldComponentUpdate(newProps, newState); + + if (__DEV__) { + warning( + shouldUpdate !== undefined, + '%s.shouldComponentUpdate(): Returned undefined instead of a ' + + 'boolean value. Make sure to return true or false.', + getName(workInProgress, instance) + ); + } + + return shouldUpdate; } const type = workInProgress.type;