(isPending: boolean)
| 373 | }); |
| 374 | |
| 375 | export function usePendingState(isPending: boolean) { |
| 376 | let [isProgressVisible, setIsProgressVisible] = useState(false); |
| 377 | useEffect(() => { |
| 378 | let timeout: ReturnType<typeof setTimeout>; |
| 379 | if (isPending) { |
| 380 | timeout = setTimeout(() => { |
| 381 | setIsProgressVisible(true); |
| 382 | }, 1000); |
| 383 | } else { |
| 384 | setIsProgressVisible(false); |
| 385 | } |
| 386 | return () => { |
| 387 | clearTimeout(timeout); |
| 388 | }; |
| 389 | }, [isPending]); |
| 390 | return {isProgressVisible}; |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Buttons allow users to perform an action. |
no outgoing calls
no test coverage detected