How to use the react-is.isElement function in react-is

To help you get started, we’ve selected a few react-is examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adazzle / react-data-grid / packages / react-data-grid / src / Canvas.js View on Github external
renderCustomRowRenderer(props) {
    const { ref, ...otherProps } = props;
    const CustomRowRenderer = this.props.rowRenderer;
    const customRowRendererProps = { ...otherProps, renderBaseRow: (p) =>  };
    if (CustomRowRenderer.type === Row) {
      // In the case where Row is specified as the custom render, ensure the correct ref is passed
      return ;
    }
    if (isValidElementType(CustomRowRenderer)) {
      return ;
    }
    if (isElement(CustomRowRenderer)) {
      return React.cloneElement(CustomRowRenderer, customRowRendererProps);
    }
  }
github adazzle / react-data-grid / packages / react-data-grid / src / HeaderCell.js View on Github external
getCell = () => {
    const { height, column, renderer } = this.props;
    if (isElement(renderer)) {
      // if it is a string, it's an HTML element, and column is not a valid property, so only pass height
      if (typeof this.props.renderer.type === 'string') {
        return React.cloneElement(renderer, { height });
      }
      return React.cloneElement(renderer, { column, height });
    }
    return renderer({ column });
  };
github Sage / carbon / src / __deprecated__ / components / form / form.component.js View on Github external
isHTMLElement(child) {
    return isElement(child) && typeof child.type === 'string';
  }
github react-cosmos / react-cosmos / packages / react-cosmos-fixture / src / FixtureCapture / shared / nodeTree / setElementAtPath.ts View on Github external
function cloneNode(value: React.ReactNode): React.ReactNode {
  if (Array.isArray(value)) {
    return value.map(n => cloneNode(n));
  }

  if (isElement(value)) {
    const el = value as React.ReactElement;
    const { children, ...otherProps } = el.props;

    return {
      ...el,
      props: {
        ...otherProps,
        children: cloneNode(children)
      }
    };
  }

  return value;
}
github facebook / react / extension / src / hydration.js View on Github external
function getDataType(data: Object): PropType {
  if (data === null) {
    return 'null';
  } else if (data === undefined) {
    return 'undefined';
  }

  if (isElement(data)) {
    return 'react_element';
  }

  if (typeof HTMLElement !== 'undefined' && data instanceof HTMLElement) {
    return 'html_element';
  }

  const type = typeof data;
  switch (type) {
    case 'boolean':
      return 'boolean';
    case 'function':
      return 'function';
    case 'number':
      if (Number.isNaN(data)) {
        return 'nan';
github youzan / zent / packages / zent / src / popover / Anchor.tsx View on Github external
render() {
    const { children } = this.props;
    if (isElement(children)) {
      return children;
    }
    return <span>{children}</span>;
  }
}
github Sage / carbon / src / __experimental__ / components / form / form.component.js View on Github external
return childrenArray.filter(Boolean).map((child, index) => {
      if (!isElement(child) || this.isHTMLElement(child)) {
        return child;
      }

      return React.cloneElement((child), {
        ...child.props,
        key: this.childKeys[index],
        childOfForm: true,
        addInputToFormState: this.addInputDataToState,
        labelAlign: isLabelRightAligned ? 'right' : 'left'
      });
    });
  }
github GSS-FED / vital-ui-kit-react / packages / form / src / input / StatelessInput.tsx View on Github external
renderIcon = (icon: IconProps, position: IconPosition) =&gt; {
    if (ReactIs.isElement(icon)) {
      return {icon};
    }
    return null;
  };