Skip to content

Commit

Permalink
Merge pull request #6296 from jontewks/add-warnings
Browse files Browse the repository at this point in the history
Add warnings for onFocusIn and onFocusOut props
  • Loading branch information
jimfb committed Mar 24, 2016
2 parents d8ee071 + a7fae7e commit 414f057
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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);
});
});
});

0 comments on commit 414f057

Please sign in to comment.