Skip to content

Commit

Permalink
Fix puppetlabs#245: Loosen type checking constraints slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhe committed May 10, 2020
1 parent 91557ea commit 0f5e9a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react-components/source/react/helpers/statics.js
Expand Up @@ -55,8 +55,13 @@ const mapObj = (obj, fn) => {
return mappedObj;
};

const componentHasType = (component, Type) =>
component && component.type && component.type === Type;
const displayNameOrName = (t) => t.displayName || t.name;

const componentHasType = (component, Type) =>
// we use displayName here instead of just name because React might use a
// proxy during rendering. We care about the underlying type because that
// describes how the component behaves.
component && component.type && displayNameOrName(component.type) === displayNameOrName(Type);

const omit = (keys, object) => {
const keySet = new Set(keys);
Expand Down

0 comments on commit 0f5e9a3

Please sign in to comment.