diff --git a/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js b/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js index 75f5dc7922d20..ee158ec600178 100644 --- a/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js +++ b/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js @@ -46,6 +46,11 @@ function warnIfInvalidElement(Component, element) { 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component' ); + warning( + !Component.childContextTypes, + '%s(...): childContextTypes cannot be defined on a functional component.', + Component.displayName || Component.name || 'Component' + ); } } diff --git a/src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js b/src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js index 9426defc77eb5..47d2e6f073f88 100644 --- a/src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js +++ b/src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js @@ -98,6 +98,27 @@ describe('ReactStatelessComponent', function() { expect(el.textContent).toBe('mest'); }); + it('should warn for childContextTypes on a functional component', () => { + spyOn(console, 'error'); + function StatelessComponentWithChildContext(props) { + return