ApiErrorMessageList.jsx 601 B

1234567891011121314151617181920212223
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ApiErrorMessage from './ApiErrorMessage';
  4. import { toArrayIfNot } from '~/utils/array-utils';
  5. function ApiErrorMessageList(props) {
  6. const errs = toArrayIfNot(props.errs);
  7. return (
  8. <>
  9. {errs.map(err => <ApiErrorMessage key={err.code} errorCode={err.code} errorMessage={err.message} targetPath={props.targetPath} />)}
  10. </>
  11. );
  12. }
  13. ApiErrorMessageList.propTypes = {
  14. errs: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
  15. targetPath: PropTypes.string,
  16. };
  17. export default ApiErrorMessageList;