title: Typescript - React Error TS2322: Type 'AppState | undefined' is not assignable to type 'ICards | undefined'
body: <p>I'm new on typescript and React. The project idea is to catch some information from a JSon file I created (back) and to display them on cards (front). I've managed to have the informations and to display them in an array, the goal now is to put this in form with reactJs. But I have the following error :</p>
  <p><em>TS2322: Type 'AppState | undefined' is not assignable to type 'ICards | undefined'.   Type 'AppState' is missing the following properties from type 'ICards': title, items, urlSuffixe  Cards.tsx(8, 3): The expected type comes from property 'cards' which is declared here on type 'IntrinsicAttributes &amp; CardsProps'.</em></p>
  <p>What did go wrong ?</p>
  <p>Cards.tsx :</p>
  <pre><code>import React, { FC, useState } from &quot;react&quot;;
  import ListCard from &quot;../ListCard/ListCard&quot;;
  import { getCards } from &quot;../../api/index&quot;;
  import { ICardItems, ICards } from &quot;../../decl&quot;;
  import &quot;./Cards.css&quot;;
  
  export interface CardsProps {
    cards: ICards | undefined;
  }
  
  const Cards = ({ cards }: CardsProps) =&gt; {
    return (
      &lt;section className=&quot;section cards&quot;&gt;
        &lt;div className=&quot;cards__wrap container&quot;&gt;
          &lt;div className=&quot;section__title&quot;&gt;
            &lt;h1&gt;{cards?.title}&lt;/h1&gt;
          &lt;/div&gt;
          {cards?.items.map((card: any) =&gt; {
            &lt;ListCard key={card.id} {...card} /&gt;;
          })}
          {/*&lt;div className=&quot;cards__list&quot;&gt;*/}
          {/*  &lt;div className=&quot;cards_list_container&quot;&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*    &lt;ListCard /&gt;*/}
          {/*  &lt;/div&gt;*/}
          {/*&lt;/div&gt;*/}
        &lt;/div&gt;
      &lt;/section&gt;
    );
  };
  
  export default Cards;
  </code></pre>
  <p>Home.tsx :</p>
  <pre><code>import React, { useState, useEffect } from &quot;react&quot;;
  import axios from &quot;axios&quot;;
  import Cards from &quot;../Cards/Cards&quot;;
  import { ICardItems, ICards } from &quot;../../decl&quot;;
  import { getCards } from &quot;../../api&quot;;
  import &quot;./Home.css&quot;;
  
  interface AppState {
    cards: ICards | undefined;
  }
  
  const Home = () =&gt; {
    const [appCards, setAppCards] = useState&lt;AppState&gt;();
  
    const fetchCards = async () =&gt; {
      const cardsPages = await getCards();
      setAppCards({ cards: cardsPages });
    };
    console.log(appCards);
  
    useEffect(() =&gt; {
      fetchCards();
    }, []);
  
    return (
      &lt;div className=&quot;home&quot;&gt;
        &lt;Cards cards={appCards} /&gt;
      &lt;/div&gt;
    );
  };
  
  export default Home;
  </code></pre>
  <p>cards.decl.ts :</p>
  <pre><code>    export type ICards = {
    title: string;
    items: ICardItems;
    urlSuffixe: string;
  };
  
  export type ICardItem = {
    id: number;
    img: string;
    gender: string;
    name: string;
  };
  
  export type ICardItems = ICardItem[];
  </code></pre>