【问题标题】:'EmployeeContext' only refers to a type, but is being used as a namespace here.ts(2702)'EmployeeContext' 仅指一种类型,但在此处用作命名空间.ts(2702)
【发布时间】:2021-11-30 11:26:59
【问题描述】:
<EmployeeContext.Provider> 
value={addEmployee, DefaultData, sortedEmployees, deleteEmployee, updateEmployee}
  {props.children};
</EmployeeContext.Provider>

这里我遇到了标题中所述的问题。请任何人帮助

【问题讨论】:

  • 如果您提供EmployeeContext 的定义会很有帮助,现在很难说可能出了什么问题。

标签: javascript reactjs typescript react-context


【解决方案1】:

也许您正在使用定义为类型的 EmployeeContext 而不是 createContext() 返回的类型,如下所示:

const EmployeeContext = React.createContext(null);

【讨论】:

    猜你喜欢
    • 2021-01-07
    • 2021-11-12
    • 1970-01-01
    • 2019-02-02
    • 2018-08-07
    • 2020-04-28
    • 2021-08-23
    • 2020-12-05
    • 2018-03-31
    相关资源
    最近更新 更多