2020-02-06 19:49:05 +01:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
type Props = {
|
2020-04-13 21:16:07 +02:00
|
|
|
children: string,
|
2020-02-06 19:49:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function ErrorText(props: Props) {
|
|
|
|
const { children } = props;
|
|
|
|
|
2020-04-13 21:16:07 +02:00
|
|
|
if (!children) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add a period to the end of error messages
|
|
|
|
let errorMessage = children[0].toUpperCase() + children.slice(1);
|
|
|
|
errorMessage = errorMessage.endsWith('.') ? errorMessage : `${errorMessage}.`;
|
|
|
|
|
|
|
|
return <span className="error__text">{errorMessage}</span>;
|
2020-02-06 19:49:05 +01:00
|
|
|
}
|