-
Notifications
You must be signed in to change notification settings - Fork 55
fix: better error handling in components #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
79ca0e9
303e465
db40c79
0f1e06b
f22aa78
39f898d
471fc53
8d27d9f
3a5939f
7248028
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,6 +334,7 @@ export const Details: React.FC<DetailsType> = ({ | |
} | ||
}, | ||
) | ||
.catch() | ||
}, | ||
[ | ||
params.appId, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { useState, useEffect, useCallback, useRef, useMemo, RefObject, useLayoutEffect } from 'react' | ||
import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react' | ||
import { | ||
showError, | ||
useThrottledEffect, | ||
|
@@ -1104,32 +1104,6 @@ export const reloadToastBody = () => { | |
) | ||
} | ||
|
||
export function useHeightObserver(callback): [RefObject<HTMLDivElement>] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contents of the custom hook seem a little convoluted and unnecessary to me. Since this is (was) being used only in TerminalView, I have refactored it out. React warns us from using useLayoutEffect anyways. The motive was probably that the actually resizing should be differed to the next repaint to prevent infinite loops in ResizeObserver callback. We shouldn't change the div size inside the resizeObserver. Thus using window.requestAnimationFrame will defer the actual resize until the next repaint saving us from the infinite resize. |
||
const ref = useRef(null) | ||
const callbackRef = useRef(callback) | ||
|
||
useLayoutEffect(() => { | ||
callbackRef.current = callback | ||
}, [callback]) | ||
|
||
const handleHeightChange = useCallback(() => { | ||
callbackRef.current?.(ref.current.clientHeight) | ||
}, [callbackRef]) | ||
|
||
useLayoutEffect(() => { | ||
if (!ref.current) { | ||
return | ||
} | ||
const observer = new ResizeObserver(handleHeightChange) | ||
observer.observe(ref.current) | ||
return () => { | ||
observer.disconnect() | ||
} | ||
}, [handleHeightChange, ref]) | ||
|
||
return [ref] | ||
} | ||
|
||
export const getDeploymentAppType = ( | ||
allowedDeploymentTypes: DeploymentAppTypes[], | ||
selectedDeploymentAppType: string, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirm with @arunjaindev