From 1e3d34c9d544f3b403c7a5921bc03bced3f0243f Mon Sep 17 00:00:00 2001 From: Tibor Postek Date: Fri, 28 Feb 2020 10:47:34 +0100 Subject: [PATCH] #117 fix error handling --- js/components/landing/Landing.js | 7 +++++-- js/components/session/withSessionManagement.js | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/js/components/landing/Landing.js b/js/components/landing/Landing.js index 89ec7b67f..bf25ac02a 100644 --- a/js/components/landing/Landing.js +++ b/js/components/landing/Landing.js @@ -2,7 +2,7 @@ * Created by ricgillams on 21/06/2018. */ import { Grid } from '@material-ui/core'; -import React, { memo, useEffect } from 'react'; +import React, { memo, useEffect, useState } from 'react'; import TargetList from '../target/targetList'; import SessionList from '../session/sessionList'; import { connect } from 'react-redux'; @@ -11,6 +11,7 @@ import * as selectionActions from '../../reducers/selection/actions'; import { DJANGO_CONTEXT } from '../../utils/djangoContext'; const Landing = memo(({ resetSelectionState, resetTargetState }) => { + const [state, setState] = useState(); let text_div; if (DJANGO_CONTEXT['authenticated'] === true) { @@ -38,7 +39,9 @@ const Landing = memo(({ resetSelectionState, resetTargetState }) => {

{ - throw new Error('my custom error'); + setState(() => { + throw Error('my custom error'); + }); }} > Welcome to Fragalysis diff --git a/js/components/session/withSessionManagement.js b/js/components/session/withSessionManagement.js index 6663f10aa..064c06aee 100644 --- a/js/components/session/withSessionManagement.js +++ b/js/components/session/withSessionManagement.js @@ -118,7 +118,16 @@ export const withSessionManagement = WrappedComponent => { setSnackBarTitle(null); setHeaderNavbarTitle(''); }; - }, [disableButtons, dispatch, sessionTitle, setHeaderNavbarTitle, setHeaderButtons, setSnackBarTitle, targetIdList, setSnackBarColor]); + }, [ + disableButtons, + dispatch, + sessionTitle, + setHeaderNavbarTitle, + setHeaderButtons, + setSnackBarTitle, + targetIdList, + setSnackBarColor + ]); return ; });