{"library":"react-is","title":"React Is","description":"react-is is a low-level utility package provided by the React team for performing \"brand checking\" on React elements and types. This library exports a set of predicate functions (e.g., `isElement`, `isValidElementType`, `isFragment`, `isMemo`) that allow developers, particularly library authors, to programmatically determine the specific type or \"brand\" of a React node without relying on potentially unstable internal properties. The current stable version is 19.2.5, aligning with the major version of React itself, indicating a close release cadence tied to the main React project. Its primary differentiation is providing a stable, official API for introspecting React elements, which is crucial for tools, renderers, and component libraries that need to handle various React node types robustly, unlike direct checks on `$$typeof` which are considered internal and unstable. It does not provide UI components but rather helper functions for type introspection.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install react-is"],"cli":null},"imports":["import { isValidElementType } from 'react-is'","import { isElement } from 'react-is'","import { isFragment } from 'react-is'","import { isMemo } from 'react-is'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import React from 'react';\nimport { isValidElementType, isElement, isFragment, isMemo, isForwardRef } from 'react-is';\n\nconst MyComponent = ({ children }) => <div>{children}</div>;\nconst MemoizedComponent = React.memo(MyComponent);\nconst ForwardRefComponent = React.forwardRef((props, ref) => <div ref={ref} />);\n\nfunction checkReactTypes() {\n  // 1. Check if a value is a valid React component type (e.g., string, class, function, Fragment)\n  console.log('Is `MyComponent` a valid element type?', isValidElementType(MyComponent));\n  console.log('Is `\"div\"` a valid element type?', isValidElementType('div'));\n  console.log('Is `null` a valid element type?', isValidElementType(null));\n\n  // 2. Check if a value is a React element instance (the result of React.createElement)\n  const elementInstance = <MyComponent />;\n  const divElement = <div>Hello</div>;\n  console.log('Is `elementInstance` a React element?', isElement(elementInstance));\n  console.log('Is `divElement` a React element?', isElement(divElement));\n  console.log('Is `MyComponent` (the component itself) a React element?', isElement(MyComponent));\n\n  // 3. Check for specific React special types\n  console.log('Is `React.Fragment` a fragment type?', isFragment(React.Fragment));\n  console.log('Is `MemoizedComponent` a memo type?', isMemo(MemoizedComponent));\n  console.log('Is `ForwardRefComponent` a forwardRef type?', isForwardRef(ForwardRefComponent));\n}\n\ncheckReactTypes();","lang":"typescript","description":"Demonstrates the core utility functions of `react-is` by checking various React component types and element instances. This example covers `isValidElementType`, `isElement`, `isFragment`, `isMemo`, and `isForwardRef` to differentiate between different forms of React nodes and types.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}