React-Table的导入问题[英] Import Issue for React-Table

本文是小编为大家收集整理的关于React-Table的导入问题的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在使用React-Table库在React中创建一个表.几天前,我使用同一库创建了一张桌子,并且没有问题.但是今天我会遇到以下错误.

尝试导入错误:'react-table'不包含默认导出(导入为'reacttable').

导入语句: 可从"反应表"进口;

我从头开始创建了多个新项目,并安装了节点模块.

有什么方法可以解决此问题?

推荐答案

您需要使用react-table-6

使用终端或命令提示符

使用此命令
> npm i react-table-6 --save

import ReactTable from 'react-table-6';

import 'react-table-6/react-table.css';

现在它将起作用

其他推荐答案

我不知道您正在使用哪个版本的React表,但请查看最新版本的代码(在这里),没有默认导出,也不是ReactTable export.

看来它现在正在使用钩子,因此您应该使用useTable钩子创建具有最新版本的表(doc 在这里).

其他推荐答案

解决了问题!!!

您必须安装

npm安装react-table-6

然后导入

import React, {Component} from 'react';

import ReactTable from 'react-table-6';

import 'react-table-6/react-table.css';

它已解决:) 参考 https://www.npmjs.coms.com/package/package/package/react-table-6pe-一个>

本文地址:https://www.itbaoku.cn/post/2129534.html

问题描述

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 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';

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

import React, {Component} from 'react';

import ReactTable from 'react-table-6';

import 'react-table-6/react-table.css';

its solved:) Reference https://www.npmjs.com/package/react-table-6