Skip to content

Commit

Permalink
Merge pull request #87 from flexpool/improvement/error-page
Browse files Browse the repository at this point in the history
Error view, hide stack trace
  • Loading branch information
march08 authored Apr 15, 2021
2 parents d3370c7 + 0451bd7 commit 23150a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
22 changes: 17 additions & 5 deletions src/components/layout/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import React from 'react';
import { CSSTransition } from 'react-transition-group';
import { clx } from 'src/utils/clx';
import styled from 'styled-components';
import './Page.scss';

import styled from 'styled-components/macro';

const ErrorContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 3rem;
margin: auto;
min-height: 70vh;
`;

type ErrorBoundaryProps = {
children: React.ReactNode;
};
Expand Down Expand Up @@ -36,12 +47,13 @@ class ErrorBoundary extends React.Component<
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
console.error('Error', this.state.error);
console.error('Error Info', this.state.errorInfo);
return (
<div>
<ErrorContainer>
<h1>Something went wrong.</h1>
{JSON.stringify(this.state.error)}
{JSON.stringify(this.state.errorInfo)}
</div>
<p>Apologies for any inconvenience! Please try again later. </p>
</ErrorContainer>
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/Home/CoinEarnings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ const CoinEarningsItem: React.FC<{ data?: ApiPoolCoinFull }> = ({ data }) => {
export const CoinEarnings = () => {
const coinsFull = useReduxState('poolCoinsFull');

const data = coinsFull.data || [];

return (
<Content>
<Spacer size="xl" />
<Container>
{coinsFull.data.length > 0 ? (
coinsFull.data.map((item) => (
<CoinEarningsItem key={item.ticker} data={item} />
))
{data.length > 0 ? (
data.map((item) => <CoinEarningsItem key={item.ticker} data={item} />)
) : (
<CoinEarningsItem />
)}
Expand Down

0 comments on commit 23150a9

Please sign in to comment.