formik-input can set ref to its inner input

This commit is contained in:
Ben Wheeler 2019-08-13 17:42:21 -04:00
parent e55d2f27d8
commit b438eed70d

View file

@ -11,6 +11,7 @@ require('./formik-input.scss');
const FormikInput = ({ const FormikInput = ({
className, className,
error, error,
setRef,
toolTip, toolTip,
validationClassName, validationClassName,
wrapperClassName, wrapperClassName,
@ -30,6 +31,8 @@ const FormikInput = ({
{fail: error}, {fail: error},
className className
)} )}
/* formik uses "innerRef" to return the actual input element */
innerRef={setRef}
{...props} {...props}
/> />
{error ? ( {error ? (
@ -48,10 +51,10 @@ const FormikInput = ({
</div> </div>
); );
FormikInput.propTypes = { FormikInput.propTypes = {
className: PropTypes.string, className: PropTypes.string,
error: PropTypes.string, error: PropTypes.string,
setRef: PropTypes.func,
toolTip: PropTypes.string, toolTip: PropTypes.string,
type: PropTypes.string, type: PropTypes.string,
validationClassName: PropTypes.string, validationClassName: PropTypes.string,