isValidElement
Checks whether a value is a React element.
Syntax
isValidElement(value) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to test. |
Returns
boolean — True if the value is a React element, false otherwise.
Examples
import { isValidElement } from 'react';
isValidElement(<p />); // true
isValidElement('hello'); // false
isValidElement({ type: 'p' }); // false
Notes
Only returns true for objects produced by createElement or JSX; strings,
numbers, arrays, and plain objects return false. Components themselves are
not elements until rendered. Rarely needed in application code; mostly used
by libraries inspecting children.