import React from 'react'; import classnames from "classnames"; export interface HelperProps { children: React.ReactElement; text?: string | React.ReactElement; error?: string | React.ReactElement; suffix?: string | React.ReactElement; } const Helper = ({ children, text, error, suffix }: HelperProps) => { const content = error ?? text; const hasContent = !!content; const hasSuffix = !!suffix; const hasError = !!error; const showHelper = hasContent || hasSuffix; return
{children} { showHelper &&
{ hasContent &&
{content}
} { hasSuffix &&
{suffix}
}
}
} export default Helper;