mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-09-22 06:32:48 +02:00

Message component works also when labelId is not defined. Not all strings originate from translations.js.
20 lines
467 B
JavaScript
20 lines
467 B
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
const Message = ({ labelId, defaultMessage }) => {
|
|
if (labelId) {
|
|
return <FormattedMessage id={labelId} defaultMessage={defaultMessage} />;
|
|
}
|
|
if (defaultMessage) {
|
|
return <span> {defaultMessage} </span>;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
Message.propTypes = {
|
|
labelId: PropTypes.string,
|
|
defaultMessage: PropTypes.string,
|
|
};
|
|
|
|
export default Message;
|