Merge pull request #6296 from jontewks/add-warnings

Add warnings for onFocusIn and onFocusOut props
This commit is contained in:
Jim 2016-03-24 08:37:45 -07:00
commit 414f057bc2
2 changed files with 19 additions and 0 deletions

View File

@ -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',

View File

@ -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);
});
});
});