Home / Function/ typeOf() — react Function Reference

typeOf() — react Function Reference

Architecture documentation for the typeOf() function in ReactIs.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  5856ecd0_0dba_38e5_b372_54a76e320186["typeOf()"]
  dfae0a13_bd8b_97d9_0260_bcccc6acd4f8["ReactIs.js"]
  5856ecd0_0dba_38e5_b372_54a76e320186 -->|defined in| dfae0a13_bd8b_97d9_0260_bcccc6acd4f8
  style 5856ecd0_0dba_38e5_b372_54a76e320186 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-is/src/ReactIs.js lines 40–77

export function typeOf(object: any): mixed {
  if (typeof object === 'object' && object !== null) {
    const $$typeof = object.$$typeof;
    switch ($$typeof) {
      case REACT_ELEMENT_TYPE:
        const type = object.type;

        switch (type) {
          case REACT_FRAGMENT_TYPE:
          case REACT_PROFILER_TYPE:
          case REACT_STRICT_MODE_TYPE:
          case REACT_SUSPENSE_TYPE:
          case REACT_SUSPENSE_LIST_TYPE:
          case REACT_VIEW_TRANSITION_TYPE:
            return type;
          default:
            const $$typeofType = type && type.$$typeof;

            switch ($$typeofType) {
              case REACT_CONTEXT_TYPE:
              case REACT_FORWARD_REF_TYPE:
              case REACT_LAZY_TYPE:
              case REACT_MEMO_TYPE:
                return $$typeofType;
              case REACT_CONSUMER_TYPE:
                return $$typeofType;
              // Fall through
              default:
                return $$typeof;
            }
        }
      case REACT_PORTAL_TYPE:
        return $$typeof;
    }
  }

  return undefined;
}

Domain

Subdomains

Frequently Asked Questions

What does typeOf() do?
typeOf() is a function in the react codebase, defined in packages/react-is/src/ReactIs.js.
Where is typeOf() defined?
typeOf() is defined in packages/react-is/src/ReactIs.js at line 40.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free