<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sahba Rezvani</title>
    <description>The latest articles on Forem by Sahba Rezvani (@sahbarezvani).</description>
    <link>https://forem.com/sahbarezvani</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3094138%2F9945b4b0-8579-416e-b175-40b674554c13.jpeg</url>
      <title>Forem: Sahba Rezvani</title>
      <link>https://forem.com/sahbarezvani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sahbarezvani"/>
    <language>en</language>
    <item>
      <title>How to fix the regular error using react-icons in React with Typescript?</title>
      <dc:creator>Sahba Rezvani</dc:creator>
      <pubDate>Sat, 26 Apr 2025 17:43:21 +0000</pubDate>
      <link>https://forem.com/sahbarezvani/how-to-fix-the-regular-error-using-react-icons-in-react-with-typescript-2cal</link>
      <guid>https://forem.com/sahbarezvani/how-to-fix-the-regular-error-using-react-icons-in-react-with-typescript-2cal</guid>
      <description>&lt;p&gt;Starting from version 19, the typings for @types/react introduced a major change!&lt;br&gt;
Now, by default, the JSX namespace is no longer available, and you have to explicitly define it yourself.&lt;/p&gt;

&lt;p&gt;🧠 Why did this happen?&lt;br&gt;
In the new versions of TypeScript and React typings:&lt;/p&gt;

&lt;p&gt;JSX.Element is not available directly unless you properly configure your environment.&lt;/p&gt;

&lt;p&gt;If your project is old, or if your tsconfig.json file is missing some settings, TypeScript will not be able to recognize JSX.&lt;/p&gt;

&lt;p&gt;💡 Solution 1 (Quick and Easy):&lt;/p&gt;

&lt;p&gt;Go to your project’s &lt;strong&gt;tsconfig.json&lt;/strong&gt; file.&lt;br&gt;
Make sure you have these important options configured like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "compilerOptions": {
    "jsx": "react-jsx",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "module": "esnext",
    "target": "esnext",
    ...
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 The most important part is:&lt;br&gt;
"jsx": "react-jsx"&lt;/p&gt;

&lt;p&gt;💡 Solution 2 (Definitive and 100% Working):&lt;/p&gt;

&lt;p&gt;Create a new file called &lt;strong&gt;global.d.ts&lt;/strong&gt; at the root of your project.&lt;br&gt;
Inside it, add the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// &amp;lt;reference types="react" /&amp;gt;
/// &amp;lt;reference types="react-dom" /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells the project:&lt;br&gt;
"Hey buddy, grab the JSX namespace from React!"&lt;/p&gt;

&lt;p&gt;But of course &lt;strong&gt;before all these&lt;/strong&gt;, you need to check if these two are installed in your project:&lt;/p&gt;

&lt;p&gt;npm install --save react react-dom&lt;br&gt;
npm install --save-dev typescript @types/react @types/react-dom&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;so the error you get is clearly because of your project's typing and not because of the way you're using the react icons!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hope it helps❤&lt;br&gt;
And if it does, please do like, share and leave me a comment.&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>reacticons</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
