【问题标题】:Property 'FC' does not exist on type 'typeof React“typeof React”类型上不存在属性“FC”
【发布时间】:2020-10-04 13:22:34
【问题描述】:

版本 “打字稿”:“^3.9.5” "@types/react": "^16.9.36", “typeof React”类型上不存在属性“FC” 我完全没有想法。

在包含 react 的 .tsx 文件中,我不断收到错误消息:

类型“typeof React”上不存在属性“FC”。

我在每个包含 react 的 .tsx 文件中都得到了这个。

我知道它必须是我的 Visual Studio 配置和项目配置的某种组合。

任何人对只影响某些工作站的检查内容有任何想法吗?在不泄露公司信息的情况下,我可以提供尽可能多的信息。

【问题讨论】:

    标签: react-tsx


    【解决方案1】:

    由于我的语法错误而遇到此问题。 如果您正在从 React native 迁移到 typescript 版本,请检查您是否正确转换了以下内容:

    function Counter(props: {initialCount: string}) {
        ...
    }
    

    interface CounterProps {
        initialCount: string
    }
    
    const Counter : React.FC<CounterProps> = (props: CounterProps) => {
        ...
    }
    

    如果这不能解决问题,那么检查是否正在导入的 React,它是从哪里导入的?

    FC 可以在node_modules/@types/react/index.d.ts/React 中的@types/react 中找到。

    【讨论】:

    • 先生,非常感谢您花时间回答问题。愿你永远快乐。
    猜你喜欢
    • 1970-01-01
    • 2021-01-09
    • 1970-01-01
    • 2019-09-14
    • 2020-08-19
    • 2017-11-06
    • 2018-11-09
    • 2018-04-26
    • 1970-01-01
    相关资源
    最近更新 更多