Skip to content

Commit

Permalink
feat: add error boundary to filter
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Apr 22, 2022
1 parent 2d2d9c6 commit e25addd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lodash.uniqwith": "^4.5.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-error-boundary": "^3.1.4",
"react-scripts": "5.0.1",
"reactstrap": "^9.0.2",
"sass": "^1.50.0",
Expand Down
12 changes: 11 additions & 1 deletion src/components/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import clsx from 'clsx';
import propTypes from 'prop-types';
import React from 'react';
import { Button, Card, CardBody, CardHeader, Col, Container, FormGroup, Input, Label, Row } from 'reactstrap';
import { ErrorBoundary } from 'react-error-boundary';
import { Alert, Button, Card, CardBody, CardHeader, Col, Container, FormGroup, Input, Label, Row } from 'reactstrap';
import { useImmerReducer } from 'use-immer';
import config from '../services/config';
import './Filter.scss';
Expand All @@ -27,6 +28,13 @@ const initialState = {
display: MODE,
};

function ErrorFallback({ error }) {
return <Alert color="danger">{error.message}</Alert>;
}
ErrorFallback.propTypes = {
error: propTypes.object.isRequired,
};

export default function Filter({ mapView }) {
const [isOpen, setIsOpen] = React.useState(true);
const buttonDiv = React.useRef(null);
Expand Down Expand Up @@ -69,6 +77,7 @@ export default function Filter({ mapView }) {
</div>
</CardHeader>
<CardBody>
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5>Display FTP Projects by:</h5>
<FormGroup check inline>
<Input
Expand Down Expand Up @@ -144,6 +153,7 @@ export default function Filter({ mapView }) {
<Col>swatch</Col>
</Row>
</Container>
</ErrorBoundary>
</CardBody>
</Card>
</>
Expand Down

0 comments on commit e25addd

Please sign in to comment.