stickers stops dragging

This commit is contained in:
Fedor Katurov 2019-12-30 15:07:59 +07:00
parent fca52df9f5
commit 58eefd5670
10 changed files with 388 additions and 175 deletions

View file

@ -0,0 +1,39 @@
import * as React from "react";
import { IStickerDump } from "$modules/Sticker";
import { Layer, FeatureGroup, Map } from "leaflet";
import { MapContext } from "$utils/context";
import { Sticker } from "$containers/map/Sticker";
interface IProps {
stickers: IStickerDump[];
is_editing: boolean;
map: Map;
}
// const { FC, useContext, useState, useEffect } = React;
const Stickers: React.FC<IProps> = React.memo(({ stickers, is_editing, map }) => {
const [layer, setLayer] = React.useState<FeatureGroup>(null);
React.useEffect(() => {
if (!map) return;
setLayer(new FeatureGroup().addTo(map));
}, [map]);
return (
<div>
{layer &&
stickers.map((sticker, index) => (
<Sticker
map={map}
sticker={sticker}
key={`${sticker.set}.${sticker.sticker}.${index}`}
/>
))}
</div>
);
// return null;
});
export { Stickers };