-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1bf85c
commit 4caccb2
Showing
7 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
import { useEffect, useRef } from 'react'; | ||
import { DependencyList, EffectCallback, useEffect, useRef } from 'react'; | ||
|
||
export const useChangeEffect = (callback: () => void, dependencies?: unknown[]) => { | ||
const isMounted = useRef(false); | ||
export const useChangeEffect = (callback: EffectCallback, dependencies: DependencyList) => { | ||
const mounted = useRef(false); | ||
|
||
useEffect( | ||
() => () => { | ||
mounted.current = false; | ||
}, | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
if (isMounted.current) { | ||
callback(); | ||
if (mounted.current) { | ||
return callback(); | ||
} | ||
|
||
return () => { | ||
isMounted.current = true; | ||
}; | ||
mounted.current = true; | ||
return undefined; | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, dependencies); | ||
}; |
8 changes: 8 additions & 0 deletions
8
idea/frontend/src/shared/ui/errorFallback/ErrorFallback.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.heading { | ||
margin-bottom: 8px; | ||
} | ||
|
||
.error { | ||
margin-bottom: 32px; | ||
color: #f24a4a; | ||
} |
16 changes: 16 additions & 0 deletions
16
idea/frontend/src/shared/ui/errorFallback/ErrorFallback.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { FallbackProps } from 'react-error-boundary'; | ||
|
||
import { Subheader } from '../subheader'; | ||
import { BackButton } from '../backButton'; | ||
import styles from './ErrorFallback.module.scss'; | ||
|
||
const ErrorFallback = ({ error }: FallbackProps) => ( | ||
<> | ||
<Subheader title="An unexpected error occured:" /> | ||
<p className={styles.error}>{error.message}</p> | ||
|
||
<BackButton /> | ||
</> | ||
); | ||
|
||
export { ErrorFallback }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ErrorFallback } from './ErrorFallback'; | ||
|
||
export { ErrorFallback }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters