isValidElement

Checks whether a value is a React element.

Since React 0.14 Spec ↗

Syntax

isValidElement(value)

Parameters

NameTypeRequiredDescription
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.

See also