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