Cache transformed body
This commit is contained in:
parent
f5a5fcf22a
commit
3fd5fd8568
@ -9,6 +9,7 @@ import LazyImage from "./LazyImage";
|
|||||||
import Hashtag from "./Hashtag";
|
import Hashtag from "./Hashtag";
|
||||||
|
|
||||||
import './Text.css'
|
import './Text.css'
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
function transformHttpLink(a) {
|
function transformHttpLink(a) {
|
||||||
try {
|
try {
|
||||||
@ -162,11 +163,13 @@ function transformText({ body, tags, users }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Text({ content, tags, users }) {
|
export default function Text({ content, tags, users }) {
|
||||||
const components = {
|
const components = useMemo(() => {
|
||||||
|
return {
|
||||||
p: (props) => transformParagraph({ body: props.children, tags, users }),
|
p: (props) => transformParagraph({ body: props.children, tags, users }),
|
||||||
a: (props) => transformHttpLink(props.href),
|
a: (props) => transformHttpLink(props.href),
|
||||||
li: (props) => transformLi({ body: props.children, tags, users }),
|
li: (props) => transformLi({ body: props.children, tags, users }),
|
||||||
}
|
};
|
||||||
|
}, [content]);
|
||||||
return <ReactMarkdown className="text" components={components}>{content}</ReactMarkdown>
|
return <ReactMarkdown className="text" components={components}>{content}</ReactMarkdown>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user