mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-03-10 09:33:47 +00:00
Refactored TranslatedTag component from class-based to functional
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {FormattedMessage, injectIntl, WrappedComponentProps} from 'react-intl';
|
||||
import * as React from 'react';
|
||||
|
||||
interface Props {
|
||||
tag: string;
|
||||
}
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
const TAG_DESCRIPTIONS = new Map([
|
||||
['ADOP', 'Adoption'],
|
||||
@@ -29,8 +24,12 @@ const TAG_DESCRIPTIONS = new Map([
|
||||
['WWW', 'WWW'],
|
||||
]);
|
||||
|
||||
function translateTag(tag: string) {
|
||||
const normalizedTag = tag.replace(/_/g, '');
|
||||
interface Props {
|
||||
tag: string;
|
||||
}
|
||||
|
||||
export function TranslatedTag(props: Props) {
|
||||
const normalizedTag = props.tag.replace(/_/g, '');
|
||||
return (
|
||||
<FormattedMessage
|
||||
id={`gedcom.${normalizedTag}`}
|
||||
@@ -38,14 +37,3 @@ function translateTag(tag: string) {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
class TranslatedTagComponent extends React.Component<
|
||||
Props & WrappedComponentProps,
|
||||
{}
|
||||
> {
|
||||
render() {
|
||||
return translateTag(this.props.tag);
|
||||
}
|
||||
}
|
||||
|
||||
export const TranslatedTag = injectIntl(TranslatedTagComponent);
|
||||
|
||||
Reference in New Issue
Block a user