File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
packages/shared/lib/components/SQLRenderer/component Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import { SQLRendererStyleWrapper } from '../style';
6
6
import { Spin , Typography } from 'antd' ;
7
7
import { tooltipsCommonProps } from '../../BasicToolTips' ;
8
8
import HighlightCode from '../../../utils/HighlightCode' ;
9
+ import { useMemo } from 'react' ;
10
+ import { isNumber } from 'lodash' ;
9
11
10
12
const Snippet : React . FC < SQLSnippetRendererProps > = ( {
11
13
rows = 10 ,
@@ -35,7 +37,14 @@ const Snippet: React.FC<SQLSnippetRendererProps> = ({
35
37
onCopyComplete,
36
38
copyIconClassName
37
39
} ) ;
38
- const slicedSql = sql && cuttingLength ? sql . slice ( 0 , cuttingLength ) : sql ;
40
+
41
+ const slicedSql = useMemo ( ( ) => {
42
+ if ( isNumber ( cuttingLength ) ) {
43
+ return sql ?. slice ( 0 , cuttingLength ) ;
44
+ }
45
+ return sql ;
46
+ } , [ cuttingLength , sql ] ) ;
47
+
39
48
const render = ( ) => {
40
49
const content = (
41
50
< SQLRendererStyleWrapper
You can’t perform that action at this time.
0 commit comments