From fdc7a1962877378690ac20e281ac00e31a5629be Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 4 Apr 2019 19:35:06 -0700 Subject: [PATCH] Fixed: Error displayed occasionally after removing series from the series list Fixes #3018 --- .../Series/Index/SeriesIndexItemConnector.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/Series/Index/SeriesIndexItemConnector.js b/frontend/src/Series/Index/SeriesIndexItemConnector.js index 86173ec7e..fa0b4ac47 100644 --- a/frontend/src/Series/Index/SeriesIndexItemConnector.js +++ b/frontend/src/Series/Index/SeriesIndexItemConnector.js @@ -42,6 +42,16 @@ function createMapStateToProps() { showSearchAction, executingCommands ) => { + + // If a series is deleted this selector may fire before the parent + // selecors, which will result in an undefined series, if that happens + // we want to return early here and again in the render function to avoid + // trying to show a series that has no information available. + + if (!series) { + return {}; + } + const isRefreshingSeries = executingCommands.some((command) => { return ( command.name === commandNames.REFRESH_SERIES && @@ -99,13 +109,19 @@ class SeriesIndexItemConnector extends Component { render() { const { + id, component: ItemComponent, ...otherProps } = this.props; + if (!id) { + return null; + } + return ( @@ -114,7 +130,7 @@ class SeriesIndexItemConnector extends Component { } SeriesIndexItemConnector.propTypes = { - id: PropTypes.number.isRequired, + id: PropTypes.number, component: PropTypes.func.isRequired, executeCommand: PropTypes.func.isRequired };