From 1227c0ff04af6fe89fd788c40d30b783f307c58d Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Wed, 27 Feb 2019 12:33:17 +0100 Subject: [PATCH] Cleaned UnivMap --- frontend/src/components/map/UnivMap.js | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/map/UnivMap.js b/frontend/src/components/map/UnivMap.js index b8020745..0b2ebbd3 100644 --- a/frontend/src/components/map/UnivMap.js +++ b/frontend/src/components/map/UnivMap.js @@ -1,8 +1,8 @@ -import React from "react"; -import CustomComponentForAPI from "../CustomComponentForAPI"; +import React, { Component } from "react"; import { connect } from "react-redux"; -import { Map, TileLayer, LayersControl, LayerGroup } from "react-leaflet"; +import PropTypes from "prop-types"; +import { Map, TileLayer, LayersControl, LayerGroup } from "react-leaflet"; import UnivMarkers from "./UnivMakers"; import { saveMainMapStatus } from "../../actions/map"; @@ -12,9 +12,9 @@ import { saveMainMapStatus } from "../../actions/map"; * Component to create the map of universities * * @class UnivMap - * @extends {CustomComponentForAPI} + * @extends {Component} */ -class UnivMap extends CustomComponentForAPI { +class UnivMap extends Component { // Initial state state = { @@ -22,6 +22,12 @@ class UnivMap extends CustomComponentForAPI { height: 800, } + constructor(props) { + super(props); + // Make sure to set the correct height on mount + this.updateDimensions(); + } + /** * Custom function to update the appropriate height of the map * @@ -37,15 +43,10 @@ class UnivMap extends CustomComponentForAPI { catch (err) { } } - componentWillMount() { - // Make sure to set the correct height on mount - this.updateDimensions(); - } - componentDidMount() { // add an event listener to resize the map when needed window.addEventListener("resize", this.updateDimensions.bind(this)); - super.componentDidMount(); + this.updateDimensions(); } componentWillUnmount() { @@ -93,7 +94,7 @@ class UnivMap extends CustomComponentForAPI { })); } - customRender() { + render() { const stamenName = "Stamen Watercolor", osmFrName = "OpenStreetMap France", esriName = "Esri WorldImagery", @@ -154,6 +155,11 @@ class UnivMap extends CustomComponentForAPI { } +UnivMap.propTypes = { + map: PropTypes.object.isRequired, + saveMainMap: PropTypes.func.isRequired +}; + const mapStateToProps = (state) => { return { map: state.app.mainMap -- GitLab