reactjs - React mui-datatable 元素类型无效
问题描述
我正在尝试构建一个基本的 mui-datatable 组件,但出现错误:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
import React, { useState, useEffect } from "react";
import { MUIDataTable } from "mui-datatables";
export default function App() {
const [deposits, setDeposits] = useState([]);
useEffect(() => {
async function fetchData() {
let arr = [];
for (let i = 0; i < 5; i++) {
arr.push({
name: "Test",
total: i + 1
});
}
setDeposits(arr);
}
fetchData();
}, []);
const columns = [
{ name: "name", label: "Name" },
{ name: "total", label: "Amount" }
];
const options = {
filterType: "dropdown",
pagination: false,
selectableRows: "none"
};
return (
<div className="App">
<MUIDataTable
title="Test Table"
data={deposits}
columns={columns}
options={options}
/>
</div>
);
}
这是沙箱:https ://codesandbox.io/s/divine-breeze-jfymy?file=/src/App.js:0-827
谢谢
解决方案
推荐阅读
- python - 无法将图像从表单上传到 Django 管理模型
- .net - 如何使用 VisualStudio docker 调试器(launchSettings.json 配置文件)从 Docker 容器公开自定义端口(TCP)?
- javascript - 在数组方法中删除输入的问题 delete
- python - 将两个具有相同开始日期和结束日期但缺少值的熊猫数据帧连接在一起
- java - 如何在旋转前获取旋转坐标的位置?
- azure - Azure AD Powershell:提取用户的上次登录时间
- python - Python OS:无法删除文件,因为它正在被另一个进程使用 - 即使在关闭文件之后
- centos7 - 需要帮助将 rpm 格式程序安装到 CentOS 7
- kubernetes - Kubernetes Coredns 无法与 IBM DNS 服务器通信(Coredns 日志显示 - i/o 超时)
- python - Gtk treeview selection 选择并返回