Firstly I install react-table-6 by npm command.

After that I will getting this error- ""Attempted import error: 'ReactTable' is not exported from 'react-table-6'".

I just fetching data from a dummy api and want to show in a table. Thanks in advance.

Here is the code -

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;```
1

There are 1 best solutions below

0
On

Here is the documentation https://github.com/tannerlinsley/react-table/tree/v6

import like this

import ReactTable from 'react-table-v6'