Skip to content

Commit 2864709

Browse files
authored
fix(useCircle): 修复闭包造成的 circle 实例引用无效问题 (#316)
fix: #315
1 parent 38f698c commit 2864709

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/circle/src/useCircle.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ export const useCircle = (props = {} as UseCircle) => {
1515
setCircle(instance);
1616
}
1717
return () => {
18-
if (circle) {
19-
map && map.remove(circle);
20-
setCircle(undefined);
21-
}
18+
setCircle((circle) => {
19+
if (circle) {
20+
map && map.remove(circle)
21+
}
22+
return undefined
23+
})
2224
};
2325
}, [map]);
2426

0 commit comments

Comments
 (0)