From e2fd02c9ff71236518382ce555bbf38660e3e540 Mon Sep 17 00:00:00 2001 From: Benjamin Coriou Date: Mon, 27 Jul 2020 17:37:24 +0200 Subject: [PATCH] Fixing an issue with missing propTypes Don't really understand the issue, but this fixes #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) --- src/ReactCursorPosition.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ReactCursorPosition.js b/src/ReactCursorPosition.js index 24e3fed8..7f5f8ec7 100644 --- a/src/ReactCursorPosition.js +++ b/src/ReactCursorPosition.js @@ -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() {