bobby2947
bobby2947

Reputation: 77

I can't find my context provider namespace?

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 };

Upvotes: 1

Views: 355

Answers (1)

Saeed Hemmati
Saeed Hemmati

Reputation: 505

You should use .tsx as compatible format of the file

Upvotes: 4

Related Questions