P
💻DeveloppementIntermediateAll AIs

Create Clean and Reusable React Components with AI

A complete prompt to generate typed, accessible, and reusable React components with custom hooks, tests, and modern best practices.

Paste in your AI

Adapt this prompt

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un développeur React senior spécialisé en architecture de composants modernes. Crée un composant React complet pour [DESCRIPTION DU COMPOSANT] destiné à une application [TYPE D'APPLICATION : e-commerce / SaaS / dashboard / blog / application mobile hybride].

Spécifications techniques à respecter :

  • Utilise React avec des composants fonctionnels et des hooks
  • TypeScript pour le typage strict des props et du state
  • Découpe le composant en sous-composants si nécessaire (composition pattern)
  • Applique le pattern de composant contrôlé/non-contrôlé selon le contexte
  • Gère les états : chargement, erreur, vide et nominal
  • Intègre les bonnes pratiques d'accessibilité (ARIA, navigation clavier, rôles sémantiques)
  • Ajoute la mémoïsation (React.memo, useMemo, useCallback) uniquement là où c'est justifié
  • Rends le composant responsive avec une approche mobile-first

Structure attendue pour chaque composant :

  1. Interface TypeScript des props avec JSDoc sur chaque propriété
  2. Le composant principal avec sa logique
  3. Les sous-composants extraits si pertinent
  4. Un hook personnalisé si la logique métier est complexe
  5. Les styles (module CSS ou Tailwind selon la stack)
  6. Un exemple d'utilisation concret avec différentes variantes
  7. Les tests unitaires essentiels avec React Testing Library

Contraintes supplémentaires :

  • Nomme les props et variables de manière explicite en anglais
  • Ajoute des valeurs par défaut raisonnables aux props optionnelles
  • Gère correctement le cleanup dans les useEffect
  • Évite les re-renders inutiles
  • Suis les conventions du projet : [CONVENTIONS : Airbnb style guide / Standard / custom]

Personalize this prompt with Léa · AI assistant

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

This prompt guides AI to produce professional-quality React components covering all critical aspects: TypeScript typing, accessibility, state management, and performance. By specifying the application type, you get a component adapted to your real business context. The three variables to customize are essential. [COMPONENT DESCRIPTION] must be precise: rather than 'a form', write 'a multi-step registration form with real-time validation'. [APPLICATION TYPE] guides UX and technical choices. [CONVENTIONS] ensures consistency with your existing codebase. The 7-point structure forces AI to deliver a complete and directly exploitable result. The custom hook separates business logic from rendering, tests with React Testing Library validate user behavior, and the usage example serves as living documentation. Adapt the constraints to your stack: remove the Tailwind part if you use styled-components, or add Storybook requirements if your team uses it.

Use Cases

Create a reusable UI component system for an internal design systemDevelop complex forms with validation and error handlingBuild dashboard components with charts and interactive filtersQuickly prototype accessible interfaces for a new feature

Expected Output

A complete TypeScript React component with: documented prop interfaces, main component and sub-component code, a custom hook if needed, associated styles, an integration example with multiple variants, and unit tests covering the main cases.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Pour éviter des composants trop génériques, demandez à l'IA de fournir un diagramme de décision (contrôlé vs non-contrôlé) avant de coder. Cela clarifie l'architecture et réduit les re-renders.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementAdvancedAll AIs

Implement canary deployments

Roll out changes safely with canary

495
💻DeveloppementIntermediateGemini

Prompt Gemini for Generating Python Code

Gemini, Google's artificial intelligence model, stands out as a powerful tool for generating Python code. With its deep understanding of programming languages and best practices, Gemini can produce functional, documented, and optimized code in seconds. Whether you are a beginner developer looking to learn Python basics or a professional wanting to speed up your workflow, a well-structured prompt makes all the difference between an approximate result and production-ready code. The main challenge lies in the precision of your request: the more you specify the context, technical constraints, expected code style, and edge cases to handle, the more Gemini will be able to generate relevant and robust code. In this guide, we offer optimized prompts that fully leverage Gemini's capabilities for Python code generation, covering different complexity levels and common use cases. You will learn how to formulate your requests to obtain clean, tested code compliant with PEP 8 standards.

988
💻DeveloppementIntermediateAll AIs

Design a Complete REST API

Design a robust and well-structured REST API with OpenAPI documentation, error handling, and security best practices.

852
💻DeveloppementIntermediateAll AIs

Sora Prompt for Generating a Database Schema

Sora, the visual generation model developed by OpenAI, offers interesting possibilities for creating visual representations of database schemas. Instead of working with traditional technical tools like dbdiagram.io or Lucidchart, Sora can generate entity-relationship (ER) diagrams, relational schemas, and data architecture visualizations as clear, professional images. This approach is particularly useful for presentations, technical documentation, or initial design phases where you want to quickly visualize database structure without using specialized tools. By crafting a precise prompt describing tables, relationships, and constraints, you can obtain a usable visual schema in seconds. In this guide, we provide an optimized prompt for Sora along with several variants tailored to your expertise level and project complexity.

534