Migrate most React class components to function components
This commit is contained in:
parent
4c9baaef80
commit
558b5a4a38
23 changed files with 1444 additions and 1775 deletions
|
@ -59,25 +59,25 @@ export type Props = {
|
|||
|
||||
const defaultRenderNonEmoji: RenderTextCallbackType = ({ text }) => text;
|
||||
|
||||
export class Emojify extends React.Component<Props> {
|
||||
public override render(): null | Array<JSX.Element | string | null> {
|
||||
const {
|
||||
isInvisible,
|
||||
renderNonEmoji = defaultRenderNonEmoji,
|
||||
sizeClass,
|
||||
text,
|
||||
} = this.props;
|
||||
export function Emojify({
|
||||
isInvisible,
|
||||
renderNonEmoji = defaultRenderNonEmoji,
|
||||
sizeClass,
|
||||
text,
|
||||
}: Props): JSX.Element {
|
||||
return (
|
||||
<>
|
||||
{splitByEmoji(text).map(({ type, value: match }, index) => {
|
||||
if (type === 'emoji') {
|
||||
return getImageTag({ isInvisible, match, sizeClass, key: index });
|
||||
}
|
||||
|
||||
return splitByEmoji(text).map(({ type, value: match }, index) => {
|
||||
if (type === 'emoji') {
|
||||
return getImageTag({ isInvisible, match, sizeClass, key: index });
|
||||
}
|
||||
if (type === 'text') {
|
||||
return renderNonEmoji({ text: match, key: index });
|
||||
}
|
||||
|
||||
if (type === 'text') {
|
||||
return renderNonEmoji({ text: match, key: index });
|
||||
}
|
||||
|
||||
throw missingCaseError(type);
|
||||
});
|
||||
}
|
||||
throw missingCaseError(type);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue