Skip to content
Snippets Groups Projects
Commit 3344eb60 authored by Chris Beer's avatar Chris Beer
Browse files

Use a selector to get the error to display

parent b1542a02
Branches
No related tags found
No related merge requests found
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import {
first,
omit,
values,
} from 'lodash';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import { ErrorDialog } from '../components/ErrorDialog'; import { ErrorDialog } from '../components/ErrorDialog';
import * as actions from '../state/actions'; import * as actions from '../state/actions';
import { getLatestError } from '../state/selectors';
/** /**
* mapStateToProps - to hook up connect * mapStateToProps - to hook up connect
...@@ -16,8 +12,7 @@ import * as actions from '../state/actions'; ...@@ -16,8 +12,7 @@ import * as actions from '../state/actions';
* @private * @private
*/ */
const mapStateToProps = state => ({ const mapStateToProps = state => ({
/* extract 'items' value and get first key-value-pair (an error) */ error: getLatestError(state),
error: first(values(omit(state.errors, 'items'))),
}); });
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment