Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
fix: full react error on staging
Browse files Browse the repository at this point in the history
  • Loading branch information
aswathy-deriv committed Oct 13, 2023
1 parent dbfae02 commit 487cfe6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { withErrorBoundary } from './reset-password'
import { WithIntl } from 'components/localization'
import HomePage from 'features/pages/home'
import { SEO } from 'components/containers'
Expand All @@ -8,7 +9,8 @@ const Home = () => {
return <HomePage />
}

export default WithIntl()(Home)
export default withErrorBoundary(Home)
WithIntl()

export const Head = ({ pageContext }: TGatsbyHead) => (
<SEO
Expand Down
14 changes: 14 additions & 0 deletions src/pages/reset-password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ const InputGroup = styled.div`
const StyledButton = styled(Button)`
margin: 0.8rem 0.4rem;
`
export const withErrorBoundary = (WrappedComponent) => {
return function ErrorBoundary(props) {
const [error, setError] = useState(null)
if (error) {
return <div>An error occured:{error.toString()}</div>
}

try {
return <WrappedComponent {...props} />
} catch (err) {
setError(err)
}
}
}

const ResetPassword = () => {
const [apiError, setApiError] = useState<string | null>('')
Expand Down

0 comments on commit 487cfe6

Please sign in to comment.