问题
I want to create a table in react using react-table library
version: "react-table": "^7.0.0-rc.15"
When I try this:
import ReactTable from 'react-table'
import 'react-table/react-table.css'
I get the following error:
Attempted import error: 'react-table' does not contain a default export (imported as 'ReactTable').
回答1:
Try to install react-table-6 [https://www.npmjs.com/package/react-table-6][1] and use instead react-table. Its work for me.
回答2:
According to the docs that's not how you use that library.
You want to import the hooks instead:
import {
useTable,
useGroupBy,
useFilters,
useSortBy,
useExpanded,
usePagination,
} from 'react-table'
回答3:
Make sure the react-table version installed; This one is works for me.
"react-table": "^6.10.3"
回答4:
0
You need to use the react-table-6
Use this command using Terminal or Command Prompt
npm i react-table-6 --save
import ReactTable from 'react-table-6';
import 'react-table-6/react-table.css';
来源:https://stackoverflow.com/questions/59796577/react-table-does-not-contain-a-default-export