Created
December 17, 2018 07:17
-
-
Save gaurav5430/c491b7aba253a2e9c17a57c028ea92a7 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
Select.propTypes = { | |
children: (props, propName, componentName) => { | |
let error; | |
const prop = props[propName]; | |
React.Children.forEach(prop, (child) => { | |
// type.name seems to work for both Class and Functional components | |
if (child.type.name !== 'Option') { | |
error = new Error(`\`${componentName}\` only accepts children of type \`Option\`.`,); | |
} | |
}); | |
return error; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment