Skip to content

Commit b9ed792

Browse files
committed
fix: hook deps issue.
1 parent 50a4f68 commit b9ed792

File tree

6 files changed

+11
-18
lines changed

6 files changed

+11
-18
lines changed

src/Label/useLabel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export default function useLabel(props = {} as UseLabel) {
2222
map.removeOverlay(label);
2323
}
2424
};
25-
}, [content, enableMassClear, label, map, offset, position, style]);
25+
// eslint-disable-next-line react-hooks/exhaustive-deps
26+
}, [map]);
2627

2728
useVisiable(label!, props);
2829
useEventProperties<BMap.Label, UseLabel>(label!, props, [

src/Map/useMap.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default function useMap(props: UseMap = {}) {
4141
});
4242
setMap(instance);
4343
}
44+
// eslint-disable-next-line react-hooks/exhaustive-deps
4445
}, [container, map]);
4546

4647
const [center, setCenter] = useState(props.center || '上海');
@@ -56,6 +57,7 @@ export default function useMap(props: UseMap = {}) {
5657
}
5758
map.centerAndZoom(center, zoom!);
5859
}
60+
// eslint-disable-next-line react-hooks/exhaustive-deps
5961
}, [center, map]);
6062

6163
const [autoLocalCity, setAutoLocalCity] = useState(props.autoLocalCity);

src/MapTypeControl/useMapTypeControl.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function useMapTypeControl(props = {} as UseMapTypeControl) {
2121
map.removeControl(instance);
2222
};
2323
}
24+
// eslint-disable-next-line react-hooks/exhaustive-deps
2425
}, [map]);
2526

2627
useVisiable(mapTypeControl!, props);

src/Marker/useMarker.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,11 @@ export default function useMarker(props = {} as UseMarker) {
102102
newMarker.setAnimation(animation);
103103
setMarker(newMarker);
104104
return () => {
105+
console.log('>>>');
105106
map.removeOverlay(newMarker);
106107
};
107-
}, [
108-
map,
109-
position.lng,
110-
position.lat,
111-
offset,
112-
icon,
113-
enableMassClear,
114-
enableDragging,
115-
enableClicking,
116-
raiseOnDrag,
117-
draggingCursor,
118-
rotation,
119-
shadow,
120-
title,
121-
animation,
122-
]);
123-
108+
// eslint-disable-next-line react-hooks/exhaustive-deps
109+
}, [map]);
124110
const [type, setType] = useState(props.type || 'loc_blue');
125111
/**
126112
* 设置标注点 `图标`

src/OverviewMapControl/useOverviewMapControl.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function useOverviewMapControl(props = {} as UseOverviewMapContro
2121
map.removeControl(instance);
2222
};
2323
}
24+
// eslint-disable-next-line react-hooks/exhaustive-deps
2425
}, [map]);
2526

2627
useVisiable(overviewMapControl!, props);

src/common/hooks.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export function useVisiable<T extends BMap.Overlay, F extends { visiable?: boole
4141
const [state, setState] = useState(visiable);
4242
useEffect(() => {
4343
if (instance && visiable !== undefined) {
44+
console.log('visiable', visiable);
4445
if (visiable) {
46+
console.log('visiable', instance);
4547
instance.show && instance.show();
4648
} else {
4749
instance.hide && instance.hide();

0 commit comments

Comments
 (0)