diff --git a/CHANGELOG.md b/CHANGELOG.md index 012b23ec..e3aa3bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] + +#### Added + +* *Nothing* + +#### Changed + +* *Nothing* + +#### Deprecated + +* *Nothing* + +#### Removed + +* *Nothing* + +#### Fixed + +* [#120](https://github.com/shlinkio/shlink-web-client/issues/120) Fixed crash when visits page is loaded and there are no visits with known cities. + + ## 2.0.2 - 2019-03-04 #### Added diff --git a/src/common/ErrorHandler.js b/src/common/ErrorHandler.js index fb641a79..6dc0af26 100644 --- a/src/common/ErrorHandler.js +++ b/src/common/ErrorHandler.js @@ -3,7 +3,7 @@ import * as PropTypes from 'prop-types'; import './ErrorHandler.scss'; import { Button } from 'reactstrap'; -const ErrorHandler = ({ location }) => class ErrorHandler extends React.Component { +const ErrorHandler = ({ location }, { error }) => class ErrorHandler extends React.Component { static propTypes = { children: PropTypes.node.isRequired, }; @@ -17,6 +17,12 @@ const ErrorHandler = ({ location }) => class ErrorHandler extends React.Componen return { hasError: true }; } + componentDidCatch(e) { + if (process.env.NODE_ENV !== 'development') { + error(e); + } + } + render() { if (this.state.hasError) { return ( diff --git a/src/common/services/provideServices.js b/src/common/services/provideServices.js index 6fcc775b..f8f5c980 100644 --- a/src/common/services/provideServices.js +++ b/src/common/services/provideServices.js @@ -7,6 +7,7 @@ import ErrorHandler from '../ErrorHandler'; const provideServices = (bottle, connect, withRouter) => { bottle.constant('window', global.window); + bottle.constant('console', global.console); bottle.serviceFactory('ScrollToTop', ScrollToTop, 'window'); bottle.decorator('ScrollToTop', withRouter); @@ -31,7 +32,7 @@ const provideServices = (bottle, connect, withRouter) => { bottle.serviceFactory('AsideMenu', AsideMenu, 'DeleteServerButton'); - bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window'); + bottle.serviceFactory('ErrorHandler', ErrorHandler, 'window', 'console'); }; export default provideServices; diff --git a/src/visits/ShortUrlVisits.js b/src/visits/ShortUrlVisits.js index cd14bc22..566074df 100644 --- a/src/visits/ShortUrlVisits.js +++ b/src/visits/ShortUrlVisits.js @@ -76,6 +76,7 @@ const ShortUrlVisits = ({ processStatsFromVisits }) => class ShortUrlVisits exte const { os, browsers, referrers, countries, cities, citiesForMap } = processStatsFromVisits( { id: this.memoizationId, visits } ); + const mapLocations = values(citiesForMap); return (