Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings for onFocusIn and onFocusOut props #6296

Merged
merged 1 commit into from
Mar 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 12 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});