Refactore MultilineText component from class-based to functional

This commit is contained in:
Przemek Wiech
2021-11-03 14:52:00 +01:00
parent 8a9294fc57
commit fe5f68e77d

View File

@@ -1,15 +1,13 @@
import * as React from 'react';
import {injectIntl, WrappedComponentProps} from 'react-intl';
import Linkify from 'react-linkify'; import Linkify from 'react-linkify';
interface Props { interface Props {
lines: (JSX.Element | string)[]; lines: (JSX.Element | string)[];
} }
function joinLines(lines: (JSX.Element | string)[]) { export function MultilineText(props: Props) {
return ( return (
<> <>
{lines.map((line, index) => ( {props.lines.map((line, index) => (
<div key={index}> <div key={index}>
<Linkify properties={{target: '_blank'}}>{line}</Linkify> <Linkify properties={{target: '_blank'}}>{line}</Linkify>
<br /> <br />
@@ -18,14 +16,3 @@ function joinLines(lines: (JSX.Element | string)[]) {
</> </>
); );
} }
class MultilineTextComponent extends React.Component<
Props & WrappedComponentProps,
{}
> {
render() {
return joinLines(this.props.lines);
}
}
export const MultilineText = injectIntl(MultilineTextComponent);