Skip to content

Commit 9c313f6

Browse files
committed
cleaned up error boundary to be simpler
1 parent 2bd6e4b commit 9c313f6

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

package-react/example/server/models/technology.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
[
2-
{
3-
"text": "test",
4-
"liked": false,
5-
"replies": [],
6-
"createComment": false,
7-
"timestamp": "Jul 24, 2024",
8-
"username": "Guest",
9-
"picture": "guest"
10-
},
112
{
123
"text": "Agree on the dev experience. Also, for those looking to optimize their app's performance, React Query's automatic data fetching on window refocus or network reconnect is a neat feature. Reduces the need for manual refetching and ensures data is always fresh.",
13-
"liked": false,
4+
"liked": true,
145
"createComment": false,
156
"timestamp": "Mar 4, 2024",
167
"username": "Marcus Holloway",
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { ErrorBoundary as ReactErrorBoundary, FallbackProps } from 'react-error-boundary';
2+
import { ErrorBoundary, FallbackProps } from 'react-error-boundary';
33

44
// Fallback component to display when an error is caught
55
const ErrorFallback: React.FC<FallbackProps> = ({ error }) => {
@@ -11,12 +11,12 @@ const ErrorFallback: React.FC<FallbackProps> = ({ error }) => {
1111
};
1212

1313
// ErrorBoundary component wrapping the ErrorFallback
14-
const ErrorBoundary: React.FC<{ children: React.ReactNode }> = ({ children }) => {
14+
const CustomErrorBoundary: React.FC<{ children: React.ReactNode }> = ({ children }) => {
1515
return (
16-
<ReactErrorBoundary FallbackComponent={ErrorFallback}>
16+
<ErrorBoundary FallbackComponent={ErrorFallback}>
1717
{children}
18-
</ReactErrorBoundary>
18+
</ErrorBoundary>
1919
);
2020
};
2121

22-
export default ErrorBoundary;
22+
export default CustomErrorBoundary;

package-react/src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import Subscription from './Subscription';
33
import TimeTravel from './TimeTravel';
4-
import ErrorBoundary from './ErrorBoundary';
4+
import CustomErrorBoundary from './CustomErrorBoundary';
55

66
function ReactQueryRewind() {
77
const [timeTravel, setTimeTravel] = useState(false);
@@ -49,13 +49,13 @@ function ReactQueryRewind() {
4949
}, []);
5050

5151
return (
52-
<ErrorBoundary>
52+
<CustomErrorBoundary>
5353
{timeTravel ? (
5454
<TimeTravel />
5555
) : (
5656
<Subscription handleMessages={handleMessages} />
5757
)}
58-
</ErrorBoundary>
58+
</CustomErrorBoundary>
5959
);
6060
}
6161

0 commit comments

Comments
 (0)