Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Hook Proposal: useTimeoutControlledFn — a manual version of useTimeoutFn

Aperta
#2,645 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Start by locating the existing useTimeoutFn implementation and its tests, since this proposal defines a manual variant of that hook. Confirm the start, cancel, reset, and readiness behavior from the issue, then add tests and documentation showing that no timeout starts on mount and that the requested API works.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

useTimeoutFn, starts the timeout automatically on mount. In our case, we needed something similar but fully manual which is a timeout only starts when we explicitly trigger it (e.g., after an API success).

Why this might be useful
  • No automatic timeout on mount
  • Full control: start(), cancel(), reset()
  • Ability to reuse the last delay (reset)
  • Useful in callbacks, controlled UI flows, etc.
API
const [isReady, cancel, start, reset] = useTimeoutControlledFn(fn, defaultMs?: number);
  • isReady() → returns true | false | null
  • cancel() → cancels the current timeout
  • start(delay?) → starts a new timeout
  • reset() → reuses last delay
Example
const [isReady, cancel, start, reset] = useTimeoutControlledFn(() => {
  console.log('Executed after delay!');
}, 1500);

// Manually start after a successful API call
const onApiSuccess = () => start();

If this sounds useful, I’m happy to prepare a full PR with tests and docs. Just wanted to get your feedback first

Lingua principale
TypeScript
Stelle
44k
Fork
3.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di streamich/react-use

Tutte le issue di streamich/react-use

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.