feat: new error boundary component

This commit is contained in:
MTG2000
2022-09-13 14:05:38 +03:00
parent dcf6aa53e6
commit 0af7ddb194
14 changed files with 127 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ import Button from "src/Components/Button/Button";
import { FiCopy } from "react-icons/fi";
import useCopyToClipboard from "src/utils/hooks/useCopyToClipboard";
import { getPropertyFromUnknown, trimText, } from "src/utils/helperFunctions";
import { useErrorHandler } from 'react-error-boundary';
@@ -33,7 +34,7 @@ export const useLnurlQuery = () => {
const doFetch = async () => {
const res = await fetchLnurlAuth();
if (!res?.encoded)
setError(true)
setError(new Error("Response doesn't contain data"))
else {
setLoading(false);
setData({
@@ -43,7 +44,7 @@ export const useLnurlQuery = () => {
timeOut = setTimeout(doFetch, 1000 * 60 * 2)
}
}
doFetch()
doFetch().catch(err => setError(err));
return () => clearTimeout(timeOut)
}, [])
@@ -64,8 +65,9 @@ export default function LoginPage() {
const canFetchIsLogged = useRef(true)
const { loadingLnurl, data: { lnurl, session_token }, error } = useLnurlQuery();
const clipboard = useCopyToClipboard()
useErrorHandler(error)
const clipboard = useCopyToClipboard()
useEffect(() => {
@@ -198,6 +200,8 @@ export default function LoginPage() {
</div>;
return (
<>
<Helmet>

View File

@@ -1,5 +1,5 @@
import { useParams, Navigate } from 'react-router-dom'
import ErrorMessage from 'src/Components/ErrorMessage/ErrorMessage';
import ErrorMessage from 'src/Components/Errors/ErrorMessage/ErrorMessage';
import { useCategoryPageQuery } from 'src/graphql';
import HeaderImage from './HeaderImage/HeaderImage';
import ProjectsGrid from './ProjectsGrid/ProjectsGrid';

View File

@@ -1,6 +1,6 @@
import ASSETS from 'src/assets';
import ErrorMessage from 'src/Components/ErrorMessage/ErrorMessage';
import ErrorMessage from 'src/Components/Errors/ErrorMessage/ErrorMessage';
import HeaderImage from 'src/features/Projects/pages/CategoryPage/HeaderImage/HeaderImage';
import ProjectsGrid from 'src/features/Projects/pages/CategoryPage/ProjectsGrid/ProjectsGrid';
import { Helmet } from "react-helmet";

View File

@@ -13,7 +13,7 @@ import { Wallet_Service } from 'src/services'
import { useProjectDetailsQuery } from 'src/graphql';
import Lightbox from 'src/Components/Lightbox/Lightbox'
import linkifyHtml from 'linkify-html';
import ErrorMessage from 'src/Components/ErrorMessage/ErrorMessage';
import ErrorMessage from 'src/Components/Errors/ErrorMessage/ErrorMessage';
import { setVoteAmount } from 'src/redux/features/vote.slice';
import { numberFormatter } from 'src/utils/helperFunctions';
import { MEDIA_QUERIES } from 'src/utils/theme';