import React, { HTMLProps } from 'react';
import { filterDOMProps, useForm } from 'uniforms';
export type ErrorsFieldProps = HTMLProps;
const defaultStyle = {
backgroundColor: 'rgba(255, 85, 0, 0.2)',
border: '1px solid rgb(255, 85, 0)',
borderRadius: '2px',
margin: '20px 0px',
padding: '10px',
};
const rowStyle = { margin: '3px' };
function ErrorsField({
children,
style = defaultStyle,
...props
}: ErrorsFieldProps) {
const { error, schema } = useForm();
return !error && !children ? null : (
{children}
{schema.getErrorMessages(error).map((message, index) => (
-
{message}
))}
);
}
export default ErrorsField;