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.
npm install react-isVerified import paths — ran on the pinned version, not inferred.
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.
Update `react-is` to match the major version of your `react` dependency. For example, if you are using `react@19.x.x`, use `react-is@19.x.x`.
Evaluate if `react-is` is truly necessary. If you only need to check if something is a rendered React element, `React.isValidElement()` is usually enough. For checking if a value is a component function/class, `typeof Component === 'function'` is often sufficient.
Understand the distinction: `isValidElementType` for *component definitions*, `isElement` for *rendered element instances*. Use the correct function based on whether you have a component constructor/type or an already created virtual DOM node.
Ensure you are using ES module `import { isValidElementType } from 'react-is'` syntax. If using TypeScript, check your `tsconfig.json` for correct `moduleResolution` settings (e.g., `bundler` or `node16`).Before rendering, use `isValidElementType` to ensure that a value intended to be a React component type is actually valid. For example, `if (isValidElementType(MyComponent)) { return <MyComponent />; }`.No dependency data recorded yet.