title: How to solve property isDialogOpen and setIsDialogOpen doesnt exist using context in react and typescript?
body: <p>i defined a context to set the isDialogOpen and setIsDialogOpen.</p>
  <p>below is the snippet for context,</p>
  <pre><code>interface DialogCtxState {
      isDialogOpen: boolean;
      setIsDialogOpen: React.Dispatch&lt;React.SetStateAction&lt;boolean&gt;&gt;;
  }
  
  const initialDialogState: DialogCtxState = {
      isDialogOpen: false,
      setIsDialogOpen: () =&gt; {},
  };
  
  const DialogContext = React.createContext&lt;DialogCtxState&gt;(
      initialDialogState
  );
  
  export const DialogContextProvider: React.FC = ({ children }) =&gt; {
      const [isDialogOpen, setIsDialogOpen] = React.useState&lt;boolean&gt;(false);
  
      return (
          &lt;DialogContext.Provider
              value={{
                  isDialogOpen,
                  setIsDialogOpen,
              }}
          &gt;
              {children}
          &lt;/DialogContext.Provider&gt;
      );
  }
  </code></pre>
  <p>In the main component i wrap context provider like below,</p>
  <pre><code>function Main() {
      return (
          &lt;DialogContext&gt;
              &lt;Child1/&gt;
              &lt;Child2/&gt;
          &lt;/DialogContext/&gt;
      );
  }
  </code></pre>
  <p>In child1 component i access the isDialogOpen and setIsDialogOpen and set isDialogOpen in handle_click like below,</p>
  <pre><code>function Child1() {
     const {isDialogOpen, setIsDialogOpen} = React.useState(DialogContext); //i get error here
     const handle_click=()=&gt; {
         setIsDialogOpen(!isDialogOpen);
     }
  
     return (
         &lt;isDialogOpen &amp;&amp; &lt;Upload/&gt;}
     );
  </code></pre>
  <p>}</p>
  <p><strong>what is the problem?</strong></p>
  <p>I get the error in child1 component at this line</p>
  <pre><code>const {isDialogOpen, setIsDialogOpen} = React.useState(DialogContext);
  </code></pre>
  <p>Property isDialogOpen doesnt exist on type '[Context, Dispatch&lt;SetStateAction&lt;Context&gt;&gt;]'</p>
  <p>Property setIsDialogOpen doesnt exist on type '[Context, Dispatch&lt;SetStateAction&lt;Context&gt;&gt;]'</p>
  <p>I am not knowing how to solve this. could someone help me thanks.</p>