/
suhushinas
/
renderless-components-examples
Обзор
Документация
Войти
/
suhushinas
/
renderless-components-examples
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/modules/map/components/GeoJSON.jsx
34 строки
627 B
SuhushinAS
fix
24 апр 2019, 04:28
24 апр 2019, 04:28
3ef582a
Код
Авторство
О чём код?
import L from 'leaflet'; import withMap from 'modules/map/context/MapContext.jsx'; import React from 'react'; class GeoJSON extends React.PureComponent { render() { return null; } componentDidMount() { this.layerAdd(); } componentDidUpdate() { this.layerDelete(); this.layerAdd(); } componentWillUnmount() { this.layerDelete(); } layerAdd() { const {geoJSON, leaflet} = this.props; this.layer = L.GeoJSON.geometryToLayer(geoJSON); leaflet.addLayer(this.layer); } layerDelete() { this.props.leaflet.removeLayer(this.layer); } } export default withMap(GeoJSON);