Skip to content

Commit 6e4e1a9

Browse files
committed
(add) Ensure edge case when the properties don't exist on the reference objects to not fire on the onMouseLeave and onMouseEnter
1 parent 2380810 commit 6e4e1a9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/app/components/AtomsRelationship.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,16 @@ function Node({ node, snapshots, dispatch, bothObj}) {
161161
stroke={isParent ? orange : blue}
162162
onMouseLeave={()=> {
163163
for (let i=0; i<bothObj[node.data.name].length; i++){
164-
dispatch(onHoverExit(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
164+
if(snapshots[0].recoilDomNode[bothObj[node.data.name][i]].length){
165+
dispatch(onHoverExit(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
166+
}
165167
}
166168
}}
167169
onMouseEnter={()=> {
168170
for (let i=0; i<bothObj[node.data.name].length; i++){
169-
dispatch(onHover(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
171+
if(snapshots[0].recoilDomNode[bothObj[node.data.name][i]].length){
172+
dispatch(onHover(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
173+
}
170174
}
171175
}}
172176
/>
@@ -231,12 +235,16 @@ function SelectorNode({ node, snapshots, dispatch, bothObj}) {
231235
stroke={selectWhite}
232236
onMouseLeave={()=> {
233237
for (let i=0; i<bothObj[node.data.name].length; i++){
234-
dispatch(onHoverExit(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
238+
if(snapshots[0].recoilDomNode[bothObj[node.data.name][i]].length){
239+
dispatch(onHoverExit(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
240+
}
235241
}
236242
}}
237243
onMouseEnter={()=> {
238244
for (let i=0; i<bothObj[node.data.name].length; i++){
245+
if(snapshots[0].recoilDomNode[bothObj[node.data.name][i]].length){
239246
dispatch(onHover(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
247+
}
240248
}
241249
}}
242250
/>

0 commit comments

Comments
 (0)