简体   繁体   English

无法从 bit.dev 导入任何内容到我的 React 项目

[英]Cannot import anything from bit.dev to my React project

I have a React project;我有一个 React 项目; I am trying to import a component from bit.dev, but it does not work for some reason.我正在尝试从 bit.dev 导入一个组件,但由于某种原因它不起作用。

I have installed the package on my terminal using:我已经使用以下命令在我的终端上安装了该软件包:

bit import nexxtway.react-rainbow/button

link: https://bit.dev/nexxtway/react-rainbow/button链接: https : //bit.dev/nexxtway/react-rainbow/button

It added to my package.json files in dependencies key as well:它也添加到我的 package.json 文件中的依赖项键中:

"dependencies": {
  "@bit/nexxtway.react-rainbow.button": "file:./components/button"
}

and I am trying to use it on my App.js file as:我试图在我的 App.js 文件中使用它:

import { Button } from '@bit/nexxtway.react-rainbow.button';

class App extends Component {
   render() {
      <Button
         label="Button Brand"
         onClick={() => alert('clicked!')}
         variant="brand" 
      />
   }

It either gives me an error or nothing it appears as an empty <div> .它要么给我一个错误,要么不显示为空的<div>

According to the docs you have imported the button incorrectly -根据文档,您错误地导入了按钮 -

change改变

import { Button } from '@bit/nexxtway.react-rainbow.button';

to

import Button from '@bit/nexxtway.react-rainbow.button';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM