src/components/Select.js
function validateChildrenAreOptionsAndMaximumOnePlaceholder(props, propName, componentName) {
  const validChildren = filterReactChildren(props[propName], (node) => (
    (isOption(node) || isSeparator(node) || isPlaceholder(node))
  ));
  if (React.Children.count(props[propName]) !== React.Children.count(validChildren)) {
    return new Error(`Invalid children supplied to \`${componentName}\`, expected an Option, Separator or Placeholder component from Belle.`);
  }

  const placeholders = filterReactChildren(props[propName], (node) => isPlaceholder(node));
  if (React.Children.count(placeholders) > 1) {
    return new Error(`Invalid children supplied to \`${componentName}\`, expected only one Placeholder component.`);
  }

  return undefined;
}
function validateChildrenAreOptionsAndMaximumOnePlaceholder(props, propName, componentName) {
  const validChildren = filterReactChildren(props[propName], (node) => (
    (isOption(node) || isSeparator(node) || isPlaceholder(node))
  ));
  if (React.Children.count(props[propName]) !== React.Children.count(validChildren)) {
    return new Error(`Invalid children supplied to \`${componentName}\`, expected an Option, Separator or Placeholder component from Belle.`);
  }

  const placeholders = filterReactChildren(props[propName], (node) => isPlaceholder(node));
  if (React.Children.count(placeholders) > 1) {
    return new Error(`Invalid children supplied to \`${componentName}\`, expected only one Placeholder component.`);
  }

  return undefined;
}
function validateChildrenAreOptionsAndMaximumOnePlaceholder ( props , propName , componentName ) { const validChildren = filterReactChildren ( props [ propName ] , ( node ) => ( ( isOption ( node ) || isSeparator ( node ) || isPlaceholder ( node ) ) ) ) ; if ( React . Children . count ( props [ propName ] ) !== React . Children . count ( validChildren ) ) { return new Error ( ` \` ${ componentName } \` ` ) ; } const placeholders = filterReactChildren ( props [ propName ] , ( node ) => isPlaceholder ( node ) ) ; if ( React . Children . count ( placeholders ) > 1 ) { return new Error ( ` \` ${ componentName } \` ` ) ; } return undefined ; }
Verifies that the children is an array containing only Options & at maximum
one Placeholder.
Verifies that the children is an array containing only Options & at maximum one Placeholder .