Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const formatMessage = ({
id,
defaultMessage,
...rest
}: {
id: string;
defaultMessage?: string;
}): string => {
if (props.formatMessage) {
return props.formatMessage({
id,
defaultMessage,
...rest,
});
}
const locales = getLocales();
if (locales[id]) {
return locales[id];
}
if (defaultMessage) {
return defaultMessage as string;
}
return id;
};