Add warnings for onFocusIn and onFocusOut props
Jon Tewksbury committed
Mar 21, 2016 at 17:22 UTC
a7fae7e4c7321c4bbb41c6e32061cccb629f2c1d
2 files changed
+19
src/renderers/dom/shared/ReactDOMComponent.js
+7
@@ -187,6 +187,13 @@ function assertValidProps(component, props) {
187
'those nodes are unexpectedly modified or duplicated. This is ' +
188
'probably not intentional.'
189
);
190
+ warning(
191
+ props.onFocusIn == null &&
192
+ props.onFocusOut == null,
193
+ 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' +
194
+ 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' +
195
+ 'are not needed/supported by React.'
196
+ );
197
}
198
invariant(
199
props.style == null || typeof props.style === 'object',
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+12
@@ -1234,5 +1234,17 @@ describe('ReactDOMComponent', function() {
1234
expect(console.error.argsForCall.length).toBe(1);
1235
expect(console.error.argsForCall[0][0]).toContain('className');
1236
});
1237
+
1238
+ it('should warn about props that are no longer supported', function() {
1239
+ spyOn(console, 'error');
1240
+ ReactTestUtils.renderIntoDocument(<div />);
1241
+ expect(console.error.argsForCall.length).toBe(0);
1242
+
1243
+ ReactTestUtils.renderIntoDocument(<div onFocusIn={() => {}} />);
1244
+ expect(console.error.argsForCall.length).toBe(1);
1245
+
1246
+ ReactTestUtils.renderIntoDocument(<div onFocusOut={() => {}} />);
1247
+ expect(console.error.argsForCall.length).toBe(2);
1248
+ });
1249
});
1250
});