Cache transformed body

This commit is contained in:
Kieran 2023-01-14 18:50:24 +00:00
parent f5a5fcf22a
commit 3fd5fd8568
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
1 changed files with 20 additions and 17 deletions

View File

@ -9,6 +9,7 @@ import LazyImage from "./LazyImage";
import Hashtag from "./Hashtag";
import './Text.css'
import { useMemo } from "react";
function transformHttpLink(a) {
try {
@ -162,11 +163,13 @@ function transformText({ body, tags, users }) {
}
export default function Text({ content, tags, users }) {
const components = {
const components = useMemo(() => {
return {
p: (props) => transformParagraph({ body: props.children, tags, users }),
a: (props) => transformHttpLink(props.href),
li: (props) => transformLi({ body: props.children, tags, users }),
}
};
}, [content]);
return <ReactMarkdown className="text" components={components}>{content}</ReactMarkdown>
}