Răsfoiți Sursa

79940 useMemo

SULLEY\ryo-h 4 ani în urmă
părinte
comite
ffe4d100a9
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      packages/ui/src/components/PagePath/PagePathLabel.jsx

+ 3 - 3
packages/ui/src/components/PagePath/PagePathLabel.jsx

@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useMemo } from 'react';
 import PropTypes from 'prop-types';
 
 import { DevidedPagePath } from '@growi/core';
@@ -9,13 +9,13 @@ export const PagePathLabel = (props) => {
   let classNames = [''];
   classNames = classNames.concat(props.additionalClassNames);
 
-  const displayPath = (reactElement) => {
+  const displayPath = useMemo((reactElement) => {
     if (props.isPathIncludedHtml) {
       // eslint-disable-next-line react/no-danger
       return <span dangerouslySetInnerHTML={{ __html: reactElement.props.children }}></span>;
     }
     return <span className={classNames.join(' ')}>{reactElement.props.children}</span>;
-  };
+  }, [props.isPathIncludedHtml]);
 
 
   if (props.isLatterOnly) {