From a7fae7e4c7321c4bbb41c6e32061cccb629f2c1d Mon Sep 17 00:00:00 2001 From: Jon Tewksbury Date: Mon, 21 Mar 2016 17:22:37 -0700 Subject: [PATCH] Add warnings for onFocusIn and onFocusOut props --- src/renderers/dom/shared/ReactDOMComponent.js | 7 +++++++ .../dom/shared/__tests__/ReactDOMComponent-test.js | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index f4a95edbe0259..3e789d33b14ac 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -187,6 +187,13 @@ function assertValidProps(component, props) { 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.' ); + warning( + props.onFocusIn == null && + props.onFocusOut == null, + 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + + 'are not needed/supported by React.' + ); } invariant( props.style == null || typeof props.style === 'object', diff --git a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js index 0fbbee1e17a9a..d932cdbf011fb 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js @@ -1234,5 +1234,17 @@ describe('ReactDOMComponent', function() { expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain('className'); }); + + it('should warn about props that are no longer supported', function() { + spyOn(console, 'error'); + ReactTestUtils.renderIntoDocument(
); + expect(console.error.argsForCall.length).toBe(0); + + ReactTestUtils.renderIntoDocument(
{}} />); + expect(console.error.argsForCall.length).toBe(1); + + ReactTestUtils.renderIntoDocument(
{}} />); + expect(console.error.argsForCall.length).toBe(2); + }); }); });