Fix composer banner timeout cleanup
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
3062967d05
commit
d9e49e4500
1 file changed
+8
-5
@@ -43,14 +43,17 @@ export interface ComposerBannerStackItem {
|
||||
|
||||
function useDismissTimeoutCleanup(timeoutRef: RefObject<ReturnType<typeof setTimeout> | null>) {
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (timeoutRef.current) {
|
||||
clearTimeout(timeoutRef.current);
|
||||
}
|
||||
};
|
||||
return () => clearDismissTimeout(timeoutRef);
|
||||
}, [timeoutRef]);
|
||||
}
|
||||
|
||||
function clearDismissTimeout(timeoutRef: RefObject<ReturnType<typeof setTimeout> | null>) {
|
||||
const timeout = timeoutRef.current;
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
interface ComposerBannerStackProps {
|
||||
readonly className?: string;
|
||||
readonly items: ReadonlyArray<ComposerBannerStackItem>;
|
||||
|
||||
Reference in new issue
Block a user