I am creating a table in react using react-table library. Few days back, I had created a table using the same library and faced no issues. But today I am getting the following error.
Attempted import error: 'react-table' does not contain a default export (imported as 'ReactTable').
Import Statement: import ReactTable from 'react-table';
I created multiple new projects from scratch and installed the node modules.
Is there any way to resolve this issue?
You're doing it in the version 6 way, and installing a later version of react-table. Based on comment found here: React table does not contain a default export, you need to install react-table-6 instead of react-table and replace it as well on your imports.
You need to use the
react-table-6
Use this command using Terminal or Command Prompt
Now it will work
I don't know which version of React Table you're using, but looking at the code of the latest version (here), there is no default export, neither a
ReactTable
export.It seems that it is now using hooks, so you should use the
useTable
hook to create a table with the latest version (doc here).Solved the problem!!!
You have to install
npm install react-table-6
and then import
its solved:) Reference https://www.npmjs.com/package/react-table-6