Hydrate body ranges for story replies

This commit is contained in:
Fedor Indutny 2022-11-09 20:59:36 -08:00 committed by GitHub
parent 9f85db3fd8
commit be6e988a95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 221 additions and 172 deletions

View file

@ -49,19 +49,15 @@ export type Props = {
renderNonEmoji?: RenderTextCallbackType;
};
const defaultRenderNonEmoji: RenderTextCallbackType = ({ text }) => text;
export class Emojify extends React.Component<Props> {
public static defaultProps: Partial<Props> = {
renderNonEmoji: ({ text }) => text,
};
public override render(): null | Array<JSX.Element | string | null> {
const { text, sizeClass, renderNonEmoji } = this.props;
// We have to do this, because renderNonEmoji is not required in our Props object,
// but it is always provided via defaultProps.
if (!renderNonEmoji) {
return null;
}
const {
text,
sizeClass,
renderNonEmoji = defaultRenderNonEmoji,
} = this.props;
return splitByEmoji(text).map(({ type, value: match }, index) => {
if (type === 'emoji') {