Estoy tratando de usar roottore para acceder a dos tiendas diferentes en mi proyecto de reacción. RoorStore.ts ={amp}gt;

import ExtractionStore from "./extractionStore"; import UserStore from "./userStore"; import { createContext } from "vm"; export class RootStore { extractionStore: ExtractionStore; userStore: UserStore; constructor() { this.extractionStore = new ExtractionStore(this); this.userStore = new UserStore(this); } } export const RootStoreContext = createContext(new RootStore()); 

Sin embargo, al intentar inyectarlo en mi componente, recibo un error:

Componente tsx ={amp}gt;

  const ExtractionDashboard: React.FC = () ={amp}gt; { const rootStore = useContext(RootStoreContext); const { loadWorkList, loadingInitial } = rootStore.extractionStore; 

Error:

 Argument of type 'Context' is not assignable to parameter of type 'Context{amp}lt;unknown{amp}gt;'. Type 'Context' is missing the following properties from type 'Context{amp}lt;unknown{amp}gt;': Provider, Consumer TS2345 7 | 8 | const ExtractionDashboard: React.FC = () ={amp}gt; { {amp}gt; 9 | const rootStore = useContext(RootStoreContext); | ^ 10 | const { loadWorkList, loadingInitial } = rootStore.extractionStore; 11 | 12 | useEffect(() ={amp}gt; { 

Estás importando correctamente la función createContext

Que tienes

 import { createContext } from "vm"; 

Lo que deberías tener

 import { createContext } from "react";