首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当导入react table-6时,我得到这个错误信息"Attempted error:'ReactTable‘is not exported from’react-table-6‘“。

当导入react table-6时,我得到这个错误信息"Attempted error:'ReactTable‘is not exported from’react-table-6‘“。
EN

Stack Overflow用户
提问于 2020-07-20 13:34:32
回答 1查看 117关注 0票数 0

首先,我使用npm命令安装react-table-6。

之后我会得到这个错误-“”尝试导入错误:'ReactTable‘没有从’react-table-6‘中导出“。

我只是从一个虚拟api中获取数据,并希望显示在一个表中。提前谢谢。

这是代码-

代码语言:javascript
复制
import React from 'react';
import { ReactTable } from 'react-table-6';
import 'react-table-6/react-table.css';

class LoginForm extends React.Component {
    constructor(props){
          super(props);
          this.state={
            username:'',
            password:'',
            contacts:[]
          }
        }

        componentDidMount() {
          fetch('http://jsonplaceholder.typicode.com/users')
          .then(res => res.json())
          .then((data) => {
            this.setState({ contacts: data })
            console.log(this.state.contacts);
          })
          .catch(console.log)
        }
    render(){
        const columns = [{
            Header: 'Name',
            accessor: 'name' 
        }, {
            Header: 'Id',
            accessor: 'id',
        }]
        return(
            <div className="wrapper">
                <div className="container">
                    <h5>LoginForm Component</h5>
                </div>
                <div className="tableData">
                    <ReactTable 
                    data = {this.state.contacts} 
                    columns = {columns}     />
                </div>
            </div>
        )
    }
}

export default LoginForm;```
EN

回答 1

Stack Overflow用户

发布于 2020-07-20 14:22:53

这是文档https://github.com/tannerlinsley/react-table/tree/v6

像这样导入

代码语言:javascript
复制
import ReactTable from 'react-table-v6'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62989196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档