File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 1- import { useState , useEffect } from 'react' ;
1+ import { useMemo } from 'react' ;
22import { Tag } from '@neo4j-ndl/react' ;
33import { appLabels , tooltips } from '../../../../utils/Constants' ;
44import { ExploreIcon } from '@neo4j-ndl/react/icons' ;
@@ -22,12 +22,8 @@ const PatternContainer = ({
2222 nodes,
2323 rels,
2424} : PatternContainerProps ) => {
25- const [ nodeCount , setNodeCount ] = useState ( 0 ) ;
26- const [ relCount , setRelCount ] = useState ( 0 ) ;
27- useEffect ( ( ) => {
28- setNodeCount ( nodes ?. length ?? 0 ) ;
29- setRelCount ( rels ?. length ?? 0 ) ;
30- } , [ nodes , rels ] ) ;
25+ const nodeCount = useMemo ( ( ) => nodes ?. length ?? 0 , [ nodes ] ) ;
26+ const relCount = useMemo ( ( ) => rels ?. length ?? 0 , [ rels ] ) ;
3127
3228 console . log ( 'count' , nodeCount ) ;
3329 return (
You can’t perform that action at this time.
0 commit comments