【问题标题】:How to use Wix Style React components with TypeScript?如何在 TypeScript 中使用 Wix Style React 组件?
【发布时间】:2020-02-22 20:24:29
【问题描述】:

我有一个 typescript + react 的项目,我想安装 wix-react 组件,而且我有很多错误

import * as React from "react";
import Button  from 'wix-style-react/Button';

export class Greeter extends React.Component<any, any> {
    render() {
        return (
          <Button onClick={() => console.log('thanks for clicking :)')}>
            Click me!
          </Button>
        )
    }
}

我遇到的第一个错误是: 找不到模块“wix-style-react/Button”的声明文件。 '/Users/../node_modules/wix-style-react/Button.js' 隐含了一个 'any' 类型。
然后我发现@types/wix-style-react, Next error: jsx element type 'Button' 没有任何构造或调用签名。 不知道怎么安装,告诉我方法

【问题讨论】:

标签: javascript reactjs typescript


【解决方案1】:

您现在可以自动获取库提供的类型。 https://github.com/wix/wix-style-react/blob/master/docs/FAQ/TYPES.MD

上述包不再维护,不再需要。

【讨论】:

    猜你喜欢
    • 2019-06-27
    • 2021-12-13
    • 2019-02-28
    • 2021-04-24
    • 2020-06-03
    • 2019-09-09
    • 1970-01-01
    • 2020-05-16
    • 2019-01-30
    相关资源
    最近更新 更多