Skip to content

Commit 7ed7aa5

Browse files
fix: unnecessary use of useEffect
1 parent b512e89 commit 7ed7aa5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/PatternContainer.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from 'react';
1+
import { useMemo } from 'react';
22
import { Tag } from '@neo4j-ndl/react';
33
import { appLabels, tooltips } from '../../../../utils/Constants';
44
import { 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 (

0 commit comments

Comments
 (0)