Skip to content

Commit

Permalink
#1999 Update InfoPanel useEffect (initialize timer variable inside us…
Browse files Browse the repository at this point in the history
…eEffect)
  • Loading branch information
porcelain11 committed Dec 29, 2022
1 parent 061d5c0 commit aef7831
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ const InfoPanel: FC<InfoPanelProps> = (props) => {
const [molecule, setMolecule] = useState<Struct | null>(null)
const childRef = useRef(null)
const groupName = sGroup?.data?.name
let timer: ReturnType<typeof setTimeout>

useEffect(() => {
let timer
if (groupStruct) {
timer = setTimeout(() => {
setMolecule(groupStruct.clone())
Expand All @@ -115,7 +115,7 @@ const InfoPanel: FC<InfoPanelProps> = (props) => {
setMolecule(null)
}
return () => clearTimeout(timer)
}, [groupName])
}, [groupName, groupStruct])

const [position, size] = getPanelPosition(clientX, clientY, render, sGroup)
const { x, y } = position
Expand Down

0 comments on commit aef7831

Please sign in to comment.