Skip to content

Commit

Permalink
Fixing an issue with missing propTypes
Browse files Browse the repository at this point in the history
Don't really understand the issue, but this fixes ethanselzer#35 by:

1. providing an empty object to Object.keys as a default
2. only emitting the event when there's actually something to send along with it

This fixes an issue I was having with another component using this one (ethanselzer/react-image-magnify)
  • Loading branch information
Coriou committed Jul 27, 2020
1 parent 0f594bb commit e2fd02c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ReactCursorPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ export default class extends React.Component {
}

getPassThroughProps() {
const ownPropNames = Object.keys(this.constructor.propTypes);
return omit(this.props, ownPropNames);
const ownPropNames = Object.keys(this.constructor.propTypes || {});
if (ownPropNames.length)
return omit(this.props, ownPropNames);
}

render() {
Expand Down

0 comments on commit e2fd02c

Please sign in to comment.