(isPending: boolean)
| 383 | }); |
| 384 | |
| 385 | export function usePendingState(isPending: boolean) { |
| 386 | let [isProgressVisible, setIsProgressVisible] = useState(false); |
| 387 | useEffect(() => { |
| 388 | let timeout: ReturnType<typeof setTimeout>; |
| 389 | if (isPending) { |
| 390 | timeout = setTimeout(() => { |
| 391 | setIsProgressVisible(true); |
| 392 | }, 1000); |
| 393 | } else { |
| 394 | // oxlint-disable-next-line react/react-compiler |
| 395 | setIsProgressVisible(false); |
| 396 | } |
| 397 | return () => { |
| 398 | clearTimeout(timeout); |
| 399 | }; |
| 400 | }, [isPending]); |
| 401 | return {isProgressVisible}; |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Buttons allow users to perform an action. |
no outgoing calls
no test coverage detected