React table does not contain a default export

放肆的年华 提交于 2020-03-03 09:13:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!