use react-innertext

This commit is contained in:
2022-01-04 18:44:49 -05:00
parent 20d8b13bb1
commit c890a8aae0
5 changed files with 11 additions and 28 deletions
-16
View File
@@ -1,16 +0,0 @@
// https://stackoverflow.com/a/60564620/1438024
const getNodeText = (node) => {
if (["string", "number"].includes(typeof node)) {
return node;
}
if (node instanceof Array) {
return node.map(getNodeText).join("");
}
if (typeof node === "object" && node) {
return getNodeText(node.props.children);
}
};
export default getNodeText;