import { useMemo } from 'react';
export default function useReactHookForm(props) {
    const { error: propError, field, fieldState, ...rest } = props;
    const error = useMemo(() => {
        if (fieldState) {
            const { error: fieldStateError } = fieldState;
            if (fieldStateError) {
                return fieldStateError.message;
            }
        }
        return propError;
    }, [propError, fieldState]);
    return {
        ...rest,
        ...field,
        error,
    };
}
