Merge pull request #6296 from jontewks/add-warnings
Add warnings for onFocusIn and onFocusOut props
This commit is contained in:
commit
414f057bc2
|
@ -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',
|
||||
|
|
|
@ -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(<div />);
|
||||
expect(console.error.argsForCall.length).toBe(0);
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<div onFocusIn={() => {}} />);
|
||||
expect(console.error.argsForCall.length).toBe(1);
|
||||
|
||||
ReactTestUtils.renderIntoDocument(<div onFocusOut={() => {}} />);
|
||||
expect(console.error.argsForCall.length).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue