Skip to content

Commit f025dd7

Browse files
committed
refactor: replace react-error-boundary with custom ErrorBoundary component and remove dependency
1 parent ec46922 commit f025dd7

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"motion": "^12.25.0",
1818
"react": "^19.2.3",
1919
"react-dom": "^19.2.3",
20-
"react-error-boundary": "^6.0.3",
2120
"spoiled": "^0.4.0",
2221
"wouter": "^3.9.0"
2322
},
@@ -76,4 +75,4 @@
7675
"vite": "^7.3.1",
7776
"vite-plugin-svgr": "^4.5.0"
7877
}
79-
}
78+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component } from "react"
2+
3+
class ErrorBoundary extends Component {
4+
constructor(props) {
5+
super(props)
6+
this.state = { hasError: false }
7+
}
8+
9+
static getDerivedStateFromError() {
10+
return { hasError: true }
11+
}
12+
13+
componentDidCatch(error, errorInfo) {
14+
console.error("ErrorBoundary caught an error:", error, errorInfo)
15+
}
16+
17+
render() {
18+
if (this.state.hasError) {
19+
return this.props.fallback
20+
}
21+
22+
return this.props.children
23+
}
24+
}
25+
26+
export default ErrorBoundary

src/pages/prototypes/Trading/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { use, Suspense } from "react"
22
import { formatPercentage } from "../../../utils/number"
3-
import { ErrorBoundary } from "react-error-boundary"
3+
import ErrorBoundary from "../../../components/ErrorBoundary"
44

55
import Text from "../../../components/Text"
66
import Page from "../../../components/Page"

0 commit comments

Comments
 (0)