pl-fe: Replace React.useMemo with React.memo
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
542ba9ab78
commit
5f4dde2590
2 changed files with 77 additions and 79 deletions
|
@ -1,6 +1,6 @@
|
|||
import parse, { Element, type HTMLReactParserOptions, domToReact, type DOMNode } from 'html-react-parser';
|
||||
import DOMPurify from 'isomorphic-dompurify';
|
||||
import React, { useMemo } from 'react';
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import Emojify from 'pl-fe/features/emoji/emojify';
|
||||
|
@ -26,8 +26,7 @@ interface IParsedContent {
|
|||
emojis?: Array<CustomEmoji>;
|
||||
}
|
||||
|
||||
const ParsedContent: React.FC<IParsedContent> = (({ html, mentions, hasQuote, emojis }) => {
|
||||
return useMemo(() => {
|
||||
const ParsedContent: React.FC<IParsedContent> = React.memo(({ html, mentions, hasQuote, emojis }) => {
|
||||
if (html.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -117,7 +116,6 @@ const ParsedContent: React.FC<IParsedContent> = (({ html, mentions, hasQuote, em
|
|||
};
|
||||
|
||||
return parse(DOMPurify.sanitize(html, { ADD_ATTR: ['target'], USE_PROFILES: { html: true } }), options);
|
||||
}, [html]);
|
||||
});
|
||||
}, (prevProps, nextProps) => prevProps.html === nextProps.html);
|
||||
|
||||
export { ParsedContent };
|
||||
|
|
|
@ -33,7 +33,7 @@ interface IEmojify {
|
|||
emojis?: Array<CustomEmoji> | Record<string, CustomEmoji>;
|
||||
}
|
||||
|
||||
const Emojify: React.FC<IEmojify> = ({ text, emojis = {} }) => React.useMemo(() => {
|
||||
const Emojify: React.FC<IEmojify> = React.memo(({ text, emojis = {} }) => {
|
||||
if (Array.isArray(emojis)) emojis = makeEmojiMap(emojis);
|
||||
|
||||
const nodes = [];
|
||||
|
@ -102,6 +102,6 @@ const Emojify: React.FC<IEmojify> = ({ text, emojis = {} }) => React.useMemo(()
|
|||
if (stack.length) nodes.push(stack);
|
||||
|
||||
return nodes;
|
||||
}, [text, emojis]);
|
||||
});
|
||||
|
||||
export { Emojify as default };
|
||||
|
|
Loading…
Reference in a new issue