{"id":69643,"date":"2023-06-02T07:22:01","date_gmt":"2023-06-02T06:22:01","guid":{"rendered":"https:\/\/kinqsta.com\/fr\/?p=69643&#038;post_type=knowledgebase&#038;preview_id=69643"},"modified":"2025-10-01T20:42:59","modified_gmt":"2025-10-01T19:42:59","slug":"erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function","status":"publish","type":"post","link":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/","title":{"rendered":"Comment corriger l&rsquo;erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb"},"content":{"rendered":"<p>Les React Hooks ont r\u00e9volutionn\u00e9 la fa\u00e7on dont nous \u00e9crivons des composants fonctionnels dans <a href=\"https:\/\/kinqsta.com\/fr\/blog\/qu-est-react-js\/\">React<\/a>, en fournissant un moyen concis et puissant de g\u00e9rer l&rsquo;\u00e9tat et les effets secondaires.<\/p>\n<p>Cependant, comme toute nouvelle fonctionnalit\u00e9, elle s&rsquo;accompagne de son propre ensemble de r\u00e8gles et de directives. Une erreur courante que les <a href=\"https:\/\/kinqsta.com\/fr\/blog\/types-de-developpeurs\/\">d\u00e9veloppeurs<\/a> React peuvent rencontrer est l&rsquo;erreur \u00ab react hooks must be called in a react function component or a custom react hook function \u00bb.<\/p>\n<p>Dans cet article, nous allons plonger dans les d\u00e9tails de cette erreur, comprendre pourquoi elle se produit et fournir les meilleures pratiques pour la corriger.<\/p>\n<div><\/div><kinsta-auto-toc heading=\"Table of Contents\" exclude=\"last\" list-style=\"arrow\" selector=\"h2\" count-number=\"-1\"><\/kinsta-auto-toc>\n<h2>Quelles sont les causes de l&rsquo;erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb ?<\/h2>\n<p>L&rsquo;utilisation des React Hooks est soumise \u00e0 certaines r\u00e8gles. De nombreux d\u00e9veloppeurs React sautent ces r\u00e8gles lorsqu&rsquo;ils apprennent React, ce qui conduit \u00e0 des erreurs. L&rsquo;une de ces erreurs est \u00ab react hooks must be called in a react function component or a custom react hook function \u00bb.<\/p>\n<p>Cette erreur se produit lorsque deux choses majeures se produisent :<\/p>\n<ul>\n<li>Utilisation de React Hooks dans des composants de classe<\/li>\n<li>Appel des React Hooks dans une fonction imbriqu\u00e9e<\/li>\n<\/ul>\n<p>Les React Hooks, tels que <code>useState<\/code>, <code>useEffect<\/code>, et <code>useContext<\/code>, sont con\u00e7us pour \u00eatre appel\u00e9s au niveau sup\u00e9rieur d&rsquo;un composant fonctionnel ou d&rsquo;une fonction de hook personnalis\u00e9e. Ils ne doivent \u00e9galement \u00eatre appel\u00e9s que dans des composants fonctionnels et non dans des composants de classe. Il s&rsquo;agit l\u00e0 de deux r\u00e8gles majeures de <a href=\"https:\/\/kinqsta.com\/fr\/blog\/react-hook-useeffect-has-a-missing-dependency\/\">React Hooks<\/a>, qui garantissent que les hooks sont utilis\u00e9s correctement et de mani\u00e8re coh\u00e9rente dans les composants React.<\/p>\n<p>Lorsque les hooks sont appel\u00e9s \u00e0 des endroits non valides, vous obtenez cette erreur : \u00ab react hooks must be called in a react function component or a custom react hook function \u00bb. Cette erreur ESLint existe en tant que sauvegarde pour emp\u00eacher les hooks d&rsquo;\u00eatre utilis\u00e9s d&rsquo;une mani\u00e8re qui peut causer un comportement inattendu et des bogues dans votre <a href=\"https:\/\/kinqsta.com\/fr\/blog\/clone-application-chatgpt\/\">application React<\/a>.<\/p>\n\n<h2>2 fa\u00e7ons de corriger l&rsquo;erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb<\/h2>\n<p>Cette erreur peut \u00eatre corrig\u00e9e de plusieurs fa\u00e7ons en fonction de la situation ou de la fa\u00e7on dont vous avez mal utilis\u00e9 le React Hook.<\/p>\n<h3>1. N&rsquo;appelez jamais les hooks React dans des composants de classe<\/h3>\n<p>Les hooks sont con\u00e7us pour fonctionner avec des <a href=\"https:\/\/kinqsta.com\/fr\/blog\/composants-web\/\">composants<\/a> fonctionnels ou des hooks personnalis\u00e9s uniquement &#8211; parce qu&rsquo;ils utilisent la pile d&rsquo;appels des composants fonctionnels pour g\u00e9rer l&rsquo;\u00e9tat et le cycle de vie du composant. Les composants de classe n&rsquo;ont pas cette pile d&rsquo;appels, vous ne pouvez donc pas utiliser les hooks directement dans ces composants.<\/p>\n<pre><code class=\"language-jsx\">import React, { useState } from 'react';\nclass Counter extends React.Component {\n    state = { count: 0 };\n    render() {\n        const [count, setCount] = useState(0);\n        \/\/ Error: React Hooks must be called in a React function component or a custom React Hook function\n        return (\n            &lt;div&gt;\n                &lt;p&gt;You clicked {count} times&lt;\/p&gt;\n                &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Click me&lt;\/button&gt;\n            &lt;\/div&gt;\n        );\n    }\n}\nexport default Counter;<\/code><\/pre>\n<p>Si vous le faites, vous obtiendrez cette erreur :<\/p>\n<figure style=\"width: 1600px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kinqsta.com\/wp-content\/uploads\/2023\/04\/react-hook-error.jpg\" alt=\"Erreur React\" width=\"1600\" height=\"125\"><figcaption class=\"wp-caption-text\">Erreur React<\/figcaption><\/figure>\n<p>Cependant, il existe plusieurs fa\u00e7ons de r\u00e9soudre ce probl\u00e8me, en fonction de vos pr\u00e9f\u00e9rences. Vous pouvez d\u00e9cider d&rsquo;utiliser <code>state<\/code> et <code>setState<\/code> avec les composants de classe, de convertir le composant en composant fonctionnel ou d&rsquo;utiliser un composant d&rsquo;ordre sup\u00e9rieur (High-Order Component ou HOC).<\/p>\n<h4>A. Convertir le composant de classe en composant fonctionnel<\/h4>\n<p>Les hooks ne peuvent fonctionner que si vous utilisez un composant fonctionnel. En effet, les hooks sont con\u00e7us pour fonctionner avec des composants fonctionnels.<\/p>\n<p>Dans l&rsquo;exemple ci-dessous, le composant de classe pr\u00e9c\u00e9dent est converti en composant fonctionnel :<\/p>\n<pre><code class=\"language-jsx\">import { useState } from 'react';\n\nfunction MyComponent(props) {\n  const [count, setCount] = useState(0);\n  return (\n    &lt;div&gt;\n      &lt;p&gt;Count: {count}&lt;\/p&gt;\n      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;\/button&gt;\n    &lt;\/div&gt;\n  );\n}<\/code><\/pre>\n<h4>B. Utiliser un composant d&rsquo;ordre sup\u00e9rieur (HOC)<\/h4>\n<p>Une fa\u00e7on d&rsquo;utiliser les hooks dans un composant de classe est d&rsquo;utiliser un composant d&rsquo;ordre sup\u00e9rieur (HOC).<\/p>\n<p>Un HOC est une fonction qui prend un composant et renvoie un nouveau composant avec des accessoires ou des fonctionnalit\u00e9s suppl\u00e9mentaires. Voici un exemple d&rsquo;utilisation d&rsquo;un HOC pour fournir des crochets \u00e0 un composant de classe :<\/p>\n<pre><code class=\"language-jsx\">import React, { useState } from 'react';\n\nfunction withHooks(WrappedComponent) {\n  return function(props) {\n    const [count, setCount] = useState(0);\n    return (\n      &lt; WrappedComponent count={count} setCount={setCount} {...props} \/&gt;\n    );\n  };\n}\n\nclass MyComponent extends React.Component {\n  render() {\n    const { count, setCount } = this.props;\n    return (\n      &lt; div&gt;\n        &lt; p&gt;Count: {count}&lt; \/p&gt;\n        &lt; button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt; \/button&gt;\n      &lt; \/div&gt;\n    );\n  }\n}\n\nexport default withHooks(MyComponent);<\/code><\/pre>\n<h4>C. Utiliser des \u00e9tats dans un composant de classe<\/h4>\n<p>Enfin, supposons que vous ne souhaitiez pas modifier la syntaxe de votre composant. Vous pouvez d\u00e9cider d&rsquo;utiliser <code>state<\/code> et <code>setState<\/code> au lieu de useState Hook :<\/p>\n<pre><code class=\"language-jsx\">import React from 'react';\n\nclass MyComponent extends React.Component {\n  constructor(props) {\n    super(props);\n    this.state = { count: 0 };\n  }\n\n  handleIncrement = () =&gt; {\n    this.setState({ count: this.state.count + 1 });\n  }\n\n  render() {\n    return (\n      &lt;div&gt;\n        &lt;p&gt;Count: {this.state.count}&lt;\/p&gt;\n        &lt;button onClick={this.handleIncrement}&gt;Increment&lt;\/button&gt;\n      &lt;\/div&gt;\n    );\n  }\n}\n\nexport default MyComponent;<\/code><\/pre>\n<h3>2. N&rsquo;appelez jamais les hooks React \u00e0 l&rsquo;int\u00e9rieur d&rsquo;une fonction imbriqu\u00e9e<\/h3>\n<p>Une r\u00e8gle claire de React Hooks est que tous les hooks doivent \u00eatre appel\u00e9s au niveau sup\u00e9rieur d&rsquo;un composant fonctionnel ou d&rsquo;une fonction de hook personnalis\u00e9e. Lorsque vous appelez un hook \u00e0 l&rsquo;int\u00e9rieur d&rsquo;une fonction imbriqu\u00e9e, vous avez enfreint cette r\u00e8gle.<\/p>\n<p>Dans l&rsquo;exemple ci-dessous, le hook <code>useState<\/code> est appel\u00e9 dans la fonction <code>handleClick<\/code>:<\/p>\n<pre><code class=\"language-jsx\">import React, { useState } from 'react';\nfunction MyComponent() {\n    let count = 0;\n    function handleClick() {\n        const [count, setCount] = useState(0);\n        setCount(count + 1);\n    }\n    return (\n        &lt;div&gt;\n            &lt;p&gt;Count: {count}&lt;\/p&gt;\n            &lt;button onClick={handleClick}&gt;Increment&lt;\/button&gt;\n        &lt;\/div&gt;\n    );\n}\n\nexport default MyComponent;<\/code><\/pre>\n<p>Vous obtiendrez l&rsquo;erreur suivante :<\/p>\n<figure style=\"width: 1600px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kinqsta.com\/wp-content\/uploads\/2023\/04\/react-hook-nested-function-error.jpg\" alt=\"Exemple d'erreur React\" width=\"1600\" height=\"149\"><figcaption class=\"wp-caption-text\">Exemple d&rsquo;erreur React<\/figcaption><\/figure>\n<p>Vous pouvez r\u00e9soudre ce probl\u00e8me en d\u00e9pla\u00e7ant le hook en dehors de la fonction &#8211; au niveau sup\u00e9rieur de votre composant fonctionnel :<\/p>\n<pre><code class=\"language-jsx\">import React, { useState } from 'react';\n\nfunction MyComponent() {\n    const [count, setCount] = useState(0);\n\n    function handleClick() {\n        setCount(count + 1);\n    }\n\n    return (\n        &lt;div&gt;\n            &lt;p&gt;Count: {count}&lt;\/p&gt;\n            &lt;button onClick={handleClick}&gt;Increment&lt;\/button&gt;\n        &lt;\/div&gt;\n    );\n}\n\nexport default MyComponent;<\/code><\/pre>\n\n<h2>R\u00e9sum\u00e9<\/h2>\n<p>Dans cet article, vous avez appris ce qui cause l&rsquo;erreur \u00ab react hooks must be called in a react function component or a custom react hook function \u00bb, et comment elle peut \u00eatre corrig\u00e9e.<\/p>\n<p>Suivez toujours les r\u00e8gles des hooks React lorsque vous travaillez et les utilisez dans vos projets React afin d&rsquo;\u00e9viter de rencontrer des erreurs de ce type.<\/p>\n<p>Vous cherchez la solution d&rsquo;h\u00e9bergement id\u00e9ale pour vos applications React ? <a href=\"https:\/\/sevalla.com\/application-hosting\/\">Essayez gratuitement<\/a> l&rsquo;h\u00e9bergement d&rsquo;applications de Kinsta !<\/p>\n<p><em>Nous aimerions avoir votre avis ! Avez-vous d\u00e9j\u00e0 rencontr\u00e9 cette erreur ? Si oui, comment l&rsquo;avez-vous r\u00e9solue ? Avez-vous utilis\u00e9 d&rsquo;autres approches qui n&rsquo;ont pas \u00e9t\u00e9 abord\u00e9es dans cet article ? Faites-nous part de vos commentaires dans la section ci-dessous !<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Les React Hooks ont r\u00e9volutionn\u00e9 la fa\u00e7on dont nous \u00e9crivons des composants fonctionnels dans React, en fournissant un moyen concis et puissant de g\u00e9rer l&rsquo;\u00e9tat et &#8230;<\/p>\n","protected":false},"author":287,"featured_media":69644,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kinsta_gated_content":false,"_kinsta_gated_content_redirect":"","footnotes":""},"tags":[],"topic":[1005,1004],"class_list":["post-69643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","topic-erreurs-react","topic-react"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.6 (Yoast SEO v24.6) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Comment corriger l&#039;erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb - Kinsta\u00ae<\/title>\n<meta name=\"description\" content=\"Apprenez \u00e0 corriger l&#039;erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Comment corriger l&#039;erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb\" \/>\n<meta property=\"og:description\" content=\"Apprenez \u00e0 corriger l&#039;erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\" \/>\n<meta property=\"og:site_name\" content=\"Kinsta\u00ae\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/kinstafrance\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-02T06:22:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-01T19:42:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"730\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Joel Olawanle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:description\" content=\"Apprenez \u00e0 corriger l&#039;erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@olawanle_joel\" \/>\n<meta name=\"twitter:site\" content=\"@kinsta_fr\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joel Olawanle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\"},\"author\":{\"name\":\"Joel Olawanle\",\"@id\":\"https:\/\/kinqsta.com\/fr\/#\/schema\/person\/efa7de30245ca15be5ce1dcacff89c07\"},\"headline\":\"Comment corriger l&rsquo;erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb\",\"datePublished\":\"2023-06-02T06:22:01+00:00\",\"dateModified\":\"2025-10-01T19:42:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\"},\"wordCount\":1026,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/#organization\"},\"image\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\",\"url\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\",\"name\":\"Comment corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb - Kinsta\u00ae\",\"isPartOf\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg\",\"datePublished\":\"2023-06-02T06:22:01+00:00\",\"dateModified\":\"2025-10-01T19:42:59+00:00\",\"description\":\"Apprenez \u00e0 corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.\",\"breadcrumb\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage\",\"url\":\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg\",\"contentUrl\":\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg\",\"width\":1460,\"height\":730,\"caption\":\"Comment corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kinqsta.com\/fr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Erreurs React\",\"item\":\"https:\/\/kinqsta.com\/fr\/sujets\/erreurs-react\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Comment corriger l&rsquo;erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kinqsta.com\/fr\/#website\",\"url\":\"https:\/\/kinqsta.com\/fr\/\",\"name\":\"Kinsta\u00ae\",\"description\":\"Solutions d&#039;h\u00e9bergement premium, rapides et s\u00e9curis\u00e9es\",\"publisher\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kinqsta.com\/fr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kinqsta.com\/fr\/#organization\",\"name\":\"Kinsta\",\"url\":\"https:\/\/kinqsta.com\/fr\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/kinqsta.com\/fr\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/12\/kinsta-logo.jpeg\",\"contentUrl\":\"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/12\/kinsta-logo.jpeg\",\"width\":500,\"height\":500,\"caption\":\"Kinsta\"},\"image\":{\"@id\":\"https:\/\/kinqsta.com\/fr\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/kinstafrance\/\",\"https:\/\/x.com\/kinsta_fr\",\"https:\/\/www.instagram.com\/kinstahosting\/\",\"https:\/\/www.linkedin.com\/company\/kinsta\/\",\"https:\/\/www.pinterest.com\/kinstahosting\/\",\"https:\/\/www.youtube.com\/c\/Kinsta\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/kinqsta.com\/fr\/#\/schema\/person\/efa7de30245ca15be5ce1dcacff89c07\",\"name\":\"Joel Olawanle\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/kinqsta.com\/fr\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/051bf577ce2c837846a1db9eef184758?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/051bf577ce2c837846a1db9eef184758?s=96&d=mm&r=g\",\"caption\":\"Joel Olawanle\"},\"description\":\"Joel is a Frontend developer working at Kinsta as a Technical Editor. He is a passionate teacher with love for open source and has written over 300 technical articles majorly around JavaScript and it's frameworks.\",\"sameAs\":[\"https:\/\/joelolawanle.com\/\",\"https:\/\/www.linkedin.com\/in\/olawanlejoel\/\",\"https:\/\/x.com\/olawanle_joel\",\"https:\/\/www.youtube.com\/@joelolawanle\"],\"gender\":\"male\",\"knowsAbout\":[\"JavaScript\",\"React\",\"Next.js\"],\"knowsLanguage\":[\"English\"],\"jobTitle\":\"Technical Editor\",\"worksFor\":\"Kinsta\",\"url\":\"https:\/\/kinqsta.com\/fr\/blog\/author\/joelolawanle\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Comment corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb - Kinsta\u00ae","description":"Apprenez \u00e0 corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/","og_locale":"fr_FR","og_type":"article","og_title":"Comment corriger l'erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb","og_description":"Apprenez \u00e0 corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.","og_url":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/","og_site_name":"Kinsta\u00ae","article_publisher":"https:\/\/www.facebook.com\/kinstafrance\/","article_published_time":"2023-06-02T06:22:01+00:00","article_modified_time":"2025-10-01T19:42:59+00:00","og_image":[{"width":1460,"height":730,"url":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg","type":"image\/jpeg"}],"author":"Joel Olawanle","twitter_card":"summary_large_image","twitter_description":"Apprenez \u00e0 corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.","twitter_image":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg","twitter_creator":"@olawanle_joel","twitter_site":"@kinsta_fr","twitter_misc":{"\u00c9crit par":"Joel Olawanle","Dur\u00e9e de lecture estim\u00e9e":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#article","isPartOf":{"@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/"},"author":{"name":"Joel Olawanle","@id":"https:\/\/kinqsta.com\/fr\/#\/schema\/person\/efa7de30245ca15be5ce1dcacff89c07"},"headline":"Comment corriger l&rsquo;erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb","datePublished":"2023-06-02T06:22:01+00:00","dateModified":"2025-10-01T19:42:59+00:00","mainEntityOfPage":{"@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/"},"wordCount":1026,"commentCount":0,"publisher":{"@id":"https:\/\/kinqsta.com\/fr\/#organization"},"image":{"@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage"},"thumbnailUrl":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg","inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/","url":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/","name":"Comment corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb - Kinsta\u00ae","isPartOf":{"@id":"https:\/\/kinqsta.com\/fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage"},"image":{"@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage"},"thumbnailUrl":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg","datePublished":"2023-06-02T06:22:01+00:00","dateModified":"2025-10-01T19:42:59+00:00","description":"Apprenez \u00e0 corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb gr\u00e2ce \u00e0 notre guide.","breadcrumb":{"@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#primaryimage","url":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg","contentUrl":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/06\/react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function.jpg","width":1460,"height":730,"caption":"Comment corriger l'erreur \u00ab React Hooks Must Be Called In a React Function Component or a Custom React Hook Function \u00bb"},{"@type":"BreadcrumbList","@id":"https:\/\/kinqsta.com\/fr\/blog\/erreur-react-hooks-must-be-called-in-a-react-function-component-or-a-custom-react-hook-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kinqsta.com\/fr\/"},{"@type":"ListItem","position":2,"name":"Erreurs React","item":"https:\/\/kinqsta.com\/fr\/sujets\/erreurs-react\/"},{"@type":"ListItem","position":3,"name":"Comment corriger l&rsquo;erreur \u00ab React Hooks must be called in a React Function Component or a Custom React Hook Function \u00bb"}]},{"@type":"WebSite","@id":"https:\/\/kinqsta.com\/fr\/#website","url":"https:\/\/kinqsta.com\/fr\/","name":"Kinsta\u00ae","description":"Solutions d&#039;h\u00e9bergement premium, rapides et s\u00e9curis\u00e9es","publisher":{"@id":"https:\/\/kinqsta.com\/fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kinqsta.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/kinqsta.com\/fr\/#organization","name":"Kinsta","url":"https:\/\/kinqsta.com\/fr\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/kinqsta.com\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/12\/kinsta-logo.jpeg","contentUrl":"https:\/\/kinqsta.com\/fr\/wp-content\/uploads\/sites\/4\/2023\/12\/kinsta-logo.jpeg","width":500,"height":500,"caption":"Kinsta"},"image":{"@id":"https:\/\/kinqsta.com\/fr\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/kinstafrance\/","https:\/\/x.com\/kinsta_fr","https:\/\/www.instagram.com\/kinstahosting\/","https:\/\/www.linkedin.com\/company\/kinsta\/","https:\/\/www.pinterest.com\/kinstahosting\/","https:\/\/www.youtube.com\/c\/Kinsta"]},{"@type":"Person","@id":"https:\/\/kinqsta.com\/fr\/#\/schema\/person\/efa7de30245ca15be5ce1dcacff89c07","name":"Joel Olawanle","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/kinqsta.com\/fr\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/051bf577ce2c837846a1db9eef184758?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/051bf577ce2c837846a1db9eef184758?s=96&d=mm&r=g","caption":"Joel Olawanle"},"description":"Joel is a Frontend developer working at Kinsta as a Technical Editor. He is a passionate teacher with love for open source and has written over 300 technical articles majorly around JavaScript and it's frameworks.","sameAs":["https:\/\/joelolawanle.com\/","https:\/\/www.linkedin.com\/in\/olawanlejoel\/","https:\/\/x.com\/olawanle_joel","https:\/\/www.youtube.com\/@joelolawanle"],"gender":"male","knowsAbout":["JavaScript","React","Next.js"],"knowsLanguage":["English"],"jobTitle":"Technical Editor","worksFor":"Kinsta","url":"https:\/\/kinqsta.com\/fr\/blog\/author\/joelolawanle\/"}]}},"acf":[],"_links":{"self":[{"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/posts\/69643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/users\/287"}],"replies":[{"embeddable":true,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/comments?post=69643"}],"version-history":[{"count":6,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/posts\/69643\/revisions"}],"predecessor-version":[{"id":69705,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/posts\/69643\/revisions\/69705"}],"alternate":[{"embeddable":true,"hreflang":"en","title":"English","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/en"},{"embeddable":true,"hreflang":"it","title":"Italian","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/it"},{"embeddable":true,"hreflang":"pt","title":"Portuguese","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/pt"},{"embeddable":true,"hreflang":"fr","title":"French","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/fr"},{"embeddable":true,"hreflang":"de","title":"German","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/de"},{"embeddable":true,"hreflang":"ja","title":"Japanese","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/jp"},{"embeddable":true,"hreflang":"nl","title":"Dutch","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/nl"},{"embeddable":true,"hreflang":"es","title":"Spanish","href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/translations\/es"},{"href":"https:\/\/kinqsta.com\/fr\/wp-json\/kinsta\/v1\/posts\/69643\/tree"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/media\/69644"}],"wp:attachment":[{"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/media?parent=69643"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/tags?post=69643"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/kinqsta.com\/fr\/wp-json\/wp\/v2\/topic?post=69643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}