Skip to content

Instantly share code, notes, and snippets.

@gaurav5430
Created December 17, 2018 07:17
Show Gist options
  • Save gaurav5430/c491b7aba253a2e9c17a57c028ea92a7 to your computer and use it in GitHub Desktop.
Save gaurav5430/c491b7aba253a2e9c17a57c028ea92a7 to your computer and use it in GitHub Desktop.
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