How to use the react-is.typeOf 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 gilbarbara / react-joyride / src / modules / propTypes.js View on Github external
const propValue = props[propName];
    let Component = propValue;

    if (!React.isValidElement(propValue) && isValidElementType(propValue)) {
      const ownProps = {
        ref: () => {},
        step: {},
      };
      Component = ;
    }

    if (
      is.string(propValue) ||
      is.number(propValue) ||
      !isValidElementType(propValue) ||
      ![Element, ForwardRef].includes(typeOf(Component))
    ) {
      return new Error(
        `Invalid ${location} \`${propFullName}\` supplied to \`${componentName}\`. Expected a React class or forwardRef.`,
      );
    }

    return undefined;
  },
);
github facebook / react / packages / react-devtools-shared / src / utils.js View on Github external
export function getDisplayNameForReactElement(
  element: React$Element,
): string | null {
  const elementType = typeOf(element);
  switch (elementType) {
    case AsyncMode:
    case ConcurrentMode:
      return 'ConcurrentMode';
    case ContextConsumer:
      return 'ContextConsumer';
    case ContextProvider:
      return 'ContextProvider';
    case ForwardRef:
      return 'ForwardRef';
    case Fragment:
      return 'Fragment';
    case Lazy:
      return 'Lazy';
    case Memo:
      return 'Memo';
github facebook / react / extension / src / hydration.js View on Github external
export function getDisplayNameForReactElement(
  element: React$Element
): string | null {
  const elementType = typeOf(element);
  switch (elementType) {
    case AsyncMode:
    case ConcurrentMode:
      return 'ConcurrentMode';
    case ContextConsumer:
      return 'ContextConsumer';
    case ContextProvider:
      return 'ContextProvider';
    case ForwardRef:
      return 'ForwardRef';
    case Fragment:
      return 'Fragment';
    case Lazy:
      return 'Lazy';
    case Memo:
      return 'Memo';