Skip to content

Commit

Permalink
refactor: move error fallback to separate component
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis authored and steveoh committed Aug 26, 2024
1 parent 990ba22 commit 6d62ab1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
15 changes: 1 addition & 14 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import esriConfig from '@arcgis/core/config';
import Graphic from '@arcgis/core/Graphic';
import Viewpoint from '@arcgis/core/Viewpoint.js';
import { Button, Drawer, Footer, Header, Sherlock, masqueradeProvider } from '@ugrc/utah-design-system';
import PropTypes from 'prop-types';
import { useEffect, useState } from 'react';
import { useOverlayTrigger } from 'react-aria';
import { ErrorBoundary } from 'react-error-boundary';
Expand All @@ -13,24 +12,12 @@ import Filter from './components/Filter';
import { useMap } from './components/hooks';
import { DnrLogo } from './components/Logo';
import config from './config';
import ErrorFallback from './ErrorFallback';

const version = import.meta.env.PACKAGE_VERSION;

console.log('application version:', version);

const ErrorFallback = ({ error }: { error: Error }) => {
return (
<div role="alert">
<p>Something went wrong:</p>
<pre style={{ color: 'red' }}>{error.message}</pre>
</div>
);
};

ErrorFallback.propTypes = {
error: PropTypes.object,
};

esriConfig.assetsPath = './assets';
const links = [
{
Expand Down
8 changes: 8 additions & 0 deletions src/ErrorFallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function ErrorFallback({ error }: { error: Error }) {
return (
<div role="alert">
<p>Something went wrong:</p>
<pre style={{ color: 'red' }}>{error.message}</pre>
</div>
);
}

0 comments on commit 6d62ab1

Please sign in to comment.