Custom React Hook
Centralize fetching logic into reusable hooks
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Create a custom React hook useData[RESOURCE_NAME] that manages API calls to the endpoint [URL_ENDPOINT]. The hook should expose: the data, a loading state (isLoading), an error state, a refetch function, and support request cancellation with AbortController. Include full TypeScript typing.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Use Cases
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Astuce : Utilisez AbortController dans le `useEffect` pour annuler la requête si le composant est démonté avant la réponse. Pensez aussi à typer le retour du hook avec un type générique `<T>` pour réutiliser le hook avec différentes ressources.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Write an Impactful Professional Apology Email
This prompt generates a structured professional apology email adapted to context, preserving credibility and the relationship with the recipient.
Social Reflection Questions
Social learning
Respond to a Difficult Email with Diplomacy and Confidence
A comprehensive prompt to draft a professional, measured response to a difficult email, maintaining control of tone and situation.
Synthetic Conclusion
Conclusion writing