You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Move error handling to separate effect
This commit is contained in:
@@ -106,10 +106,6 @@ const useMapWithStyle = ({
|
|||||||
});
|
});
|
||||||
setGeolocate(geolocate);
|
setGeolocate(geolocate);
|
||||||
map.addControl(geolocate);
|
map.addControl(geolocate);
|
||||||
geolocate.on("error", onGeolocateError);
|
|
||||||
return () => {
|
|
||||||
geolocate.off("error", onGeolocateError);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (!allowGeolocate && geolocate) {
|
if (!allowGeolocate && geolocate) {
|
||||||
map.removeControl(geolocate);
|
map.removeControl(geolocate);
|
||||||
@@ -117,6 +113,15 @@ const useMapWithStyle = ({
|
|||||||
}
|
}
|
||||||
}, [map, geolocate, allowGeolocate]);
|
}, [map, geolocate, allowGeolocate]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (geolocate) {
|
||||||
|
geolocate.on("error", onGeolocateError);
|
||||||
|
return () => {
|
||||||
|
geolocate.off("error", onGeolocateError);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, [geolocate]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
map,
|
map,
|
||||||
bodyId,
|
bodyId,
|
||||||
|
@@ -30,27 +30,3 @@ exports[`PictureInPictureDragger when rendering the dragger with PiP content 1 a
|
|||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`PictureInPictureDragger when rendering the dragger with PiP content 1 and rerendering PiP content 1 should not change the PiP content: pip-content-1 1`] = `
|
|
||||||
<div>
|
|
||||||
<aside
|
|
||||||
style="transform: translateX(680px) translateY(478px);"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
content 1
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`PictureInPictureDragger when rendering the dragger with PiP content 1 should render the PiP content: pip-content-1 1`] = `
|
|
||||||
<div>
|
|
||||||
<aside
|
|
||||||
style="transform: translateX(680px) translateY(478px);"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
content 1
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
Reference in New Issue
Block a user