import { isValidElement, type ReactNode } from 'react'

export function isReactNode(value: unknown): value is ReactNode {
  return (
    value === null ||
    value === undefined ||
    typeof value === 'string' ||
    typeof value === 'number' ||
    typeof value === 'boolean' ||
    isValidElement(value) ||
    (Array.isArray(value) && value.every(isReactNode))
  )
}
