Skip to content

Instantly share code, notes, and snippets.

@lelandrichardson
Created October 16, 2016 19:33
Show Gist options
  • Save lelandrichardson/83b7bbc4eabd4f37789eb1723b551193 to your computer and use it in GitHub Desktop.
Save lelandrichardson/83b7bbc4eabd4f37789eb1723b551193 to your computer and use it in GitHub Desktop.
function ReactComponentPropType(props, propName, componentName, ...rest) {
const Component = props[propName];
if (Component === undefined) return null;
if (typeof Component === 'function' && Component.prototype.isReactComponent) {
// it's a real react component
return null;
} else {
return new Error(`${componentName}.${propName} is expected to be a React component.`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment