首页 > 解决方案 > 无法在 TS 中使用模块,新手在这里

问题描述

所以我一直在尝试使用 React Native 和 Typescript 构建 Web 应用程序,但我无法添加按钮。我可以在组件中添加按钮,然后在我的 tsx 中使用它,但是当我尝试从 github 添加此按钮时,https://github.com/rcaferati/react-native-really-awesome-button 当我尝试添加这个按钮到我的代码我在 TS 中收到此错误。

import AwesomeButtonRick from "react-native-really-awesome-button";

function Button() {
  return <AwesomeButtonRick>Text</AwesomeButtonRick>;
}

另外,我使用 AwesomeButton 还是 AwesomeButtonRick 也没关系。

'AwesomeButtonRick' 不能用作 JSX 组件。它的实例类型“AwesomeButton”不是有效的 JSX 元素。“AwesomeButton”类型缺少“ElementClass”类型的以下属性:render、context、setState、forceUpdate 和 3 more.ts(2786)

我尝试更新依赖项和所有内容,你能告诉我我做错了什么吗?

标签: typescriptreact-nativenative

解决方案


推荐阅读