UseAfter manages a timeout lifecycle within a component. It creates a timer that calls the provided function after the specified duration. The timer is automatically canceled on dependency changes or component unmount. This hook must be called within a component context.
(duration time.Duration, timeoutFn func(), deps []any)
| 209 | // The timer is automatically canceled on dependency changes or component unmount. |
| 210 | // This hook must be called within a component context. |
| 211 | func UseAfter(duration time.Duration, timeoutFn func(), deps []any) { |
| 212 | UseGoRoutine(func(ctx context.Context) { |
| 213 | timer := time.NewTimer(duration) |
| 214 | defer timer.Stop() |
| 215 | |
| 216 | select { |
| 217 | case <-ctx.Done(): |
| 218 | return |
| 219 | case <-timer.C: |
| 220 | timeoutFn() |
| 221 | } |
| 222 | }, deps) |
| 223 | } |
| 224 | |
| 225 | // ModalConfig contains all configuration options for modals |
| 226 | type ModalConfig struct { |
nothing calls this directly
no test coverage detected