Creators to follow

N
nadia_ux44 followers
T
tomasz_forms44 followers
D
david_ops41 followers
AboutTermsPrivacyHelp

© 2026 teliprompt

MA
marcus_react
4 months ago•
Coding

Custom React hook with TypeScript generics and full test suite

Claude Sonnet 4.6
code output
#react-hooks
#typescript
#testing
#async
#generics
Views
2.0K
Copies
346
Likes
326
Comments
0
Copy rate
17.0%

Prompt

Build a reusable custom React hook called [hook_name] that [hook_purpose]. Requirements:

- Full TypeScript with generics where applicable
- Proper cleanup on unmount
- Handle loading, error, and success states
- Support cancellation of in-flight requests
- Memoize callbacks to prevent unnecessary re-renders
- Include a comprehensive Vitest test suite with React Testing Library
- Export named only (no default export)
- Handle race conditions (stale closures)

Customise this prompt

Fill in 2 variables to personalise this prompt

Preview
Build a reusable custom React hook called [hook_name] that [hook_purpose]. Requirements: - Full TypeScript with generics where applicable - Proper cleanup on unmount - Handle loading, error, and success states - Support cancellation of in-flight requests - Memoize callbacks to prevent unnecessary re-renders - Include a comprehensive Vitest test suite with React Testing Library - Export named only (no default export) - Handle race conditions (stale closures)

Example output

Related prompts

Async iterators and generators in modern JavaScript: a working guideby @olivia_test
Coding
TypeScript type narrowing cheat sheet with runnable examplesby @marcus_react
Coding
CLI tool builder with argument parsing and colored outputby @nikolai_rust
Coding
Convert JavaScript to strict TypeScript with full type safetyby @marcus_react
Coding