Created
October 16, 2016 19:33
-
-
Save lelandrichardson/83b7bbc4eabd4f37789eb1723b551193 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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