Trending today

1

Create a deep RPG character backstory with motivations, flaws, and arc potential

11.8K views
2

Anomaly detection with rolling z-score windows in SQL

11.8K views
3

30-day social media content calendar with post templates

11.6K views
4

Structured logging with correlation IDs across microservices

11.4K views
5

Legacy JavaScript to modern ES2023 refactor

10.9K views

Creators to follow

N
nadia_ux45 followers
D
david_ops45 followers
P
priya_design44 followers
AboutTermsPrivacyHelp

© 2026 teliprompt

MA
marcus_react
27 days 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
9.5K
Copies
2.9K
Likes
1.0K
Comments
0
Copy rate
30.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

Task automation script with retry logic and notificationsby @jess_python
Coding
Legacy JavaScript to modern ES2023 refactorby @marcus_react
Coding
Python dataclass to Pydantic v2 model converterby @jess_python
Coding
Regex builder with visual explanation and test casesby @mei_swift
Coding