APIs
isValidElement
Determines whether a value is a React element, not whether it is renderable. Strings, arrays and numbers may be valid React nodes without being elements.
Formal Syntax & Structure
react syntaxreact
isValidElement(value)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | unknown | Value to inspect. |
Return Value
boolean
True only for a React element.
Working Example
Example Snippetreact
import { createElement, isValidElement } from 'react';console.log(isValidElement(createElement('p', null, 'Ready')));console.log(isValidElement('Ready'));