From 66fa6fbe52216d1d3ede607ec0852e3a70a4f072 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 19 Oct 2023 22:57:56 +0800 Subject: [PATCH] Memoize getHTMLText --- src/utils/getHTMLText.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/getHTMLText.jsx b/src/utils/getHTMLText.jsx index fc03b647..142f7e7d 100644 --- a/src/utils/getHTMLText.jsx +++ b/src/utils/getHTMLText.jsx @@ -1,3 +1,5 @@ +import mem from './mem'; + const div = document.createElement('div'); function getHTMLText(html) { if (!html) return ''; @@ -10,4 +12,4 @@ function getHTMLText(html) { return div.innerText.replace(/[\r\n]{3,}/g, '\n\n').trim(); } -export default getHTMLText; +export default mem(getHTMLText);