UNPKG

@wq/material-web

Version:

Web bindings for @wq/material

27 lines (26 loc) 680 B
import React from "react"; import { useFormikContext, getIn } from "formik"; import { FormHelperText } from "@mui/material"; import PropTypes from "prop-types"; export default function HelperText({ name, hint }) { const { errors, touched } = useFormikContext(), error = getIn(errors, name), showError = !!error && !!getIn(touched, name); if (showError) { hint = error; } if (!hint) { return null; } return /*#__PURE__*/ React.createElement( FormHelperText, { error: !!showError, }, hint ); } HelperText.propTypes = { name: PropTypes.string, hint: PropTypes.string, };