Home > Enterprise >  I can't find my context provider namespace?
I can't find my context provider namespace?

Time:11-24

Intellisense complains that it can't find the namespace WorkorderListContext in WorkorderListProvider return, but it's in the same file?

import { createContext } from 'react';

interface IWorkorderListContext {
    items: any[];
    setItems?: (itemsArray: []) => void;
    getItems?: () => [];
}

const defaultState = {
    items: []
};

const WorkorderListContext = createContext<IWorkorderListContext>(defaultState);

const WorkorderListProvider = ({ children }: { children: any }) => {
    return (
        <WorkorderListContext.Provider>   **<---- Error: Cannot find namespace ts(2503)**
            {children}
        </WorkorderListContext.Provider>
    )
}

export { WorkorderListProvider, WorkorderListContext };

CodePudding user response:

You should use .tsx as compatible format of the file

  • Related