tissue/resources/assets/js/components/FieldError.tsx

17 lines
541 B
TypeScript
Raw Normal View History

2020-08-17 18:17:38 +09:00
import React from 'react';
2020-08-17 16:08:35 +09:00
type FieldErrorProps = {
errors?: string[];
};
export const FieldError: React.FC<FieldErrorProps> = ({ errors }) =>
(errors && errors.length > 0 && <div className="invalid-feedback">{errors[0]}</div>) || null;
export const StandaloneFieldError: React.FC<FieldErrorProps> = ({ errors }) =>
(errors && errors.length > 0 && (
<div className="form-group col-sm-12" style={{ marginTop: '-1rem' }}>
<small className="text-danger">{errors[0]}</small>
</div>
)) ||
null;