import { getIn, useFormikContext } from 'formik';

interface ErrorsType {
  [property: string]: string | undefined;
}

export const useFormikError = (name: string): string | undefined => {
  const { errors } = useFormikContext();
  return errors && getIn(errors as ErrorsType, name);
};
