I’m trying to render the data using ant design table but it doesn’t work. I think it’s because of the object key "children" in my response.
When I run my code I get the error:
TypeError: (data || []).forEach is not a function
I would also like to note that I have uploaded csv file data without "children" column and it works perfectly.
My response:
import React, { useState } from "react";
import { parse } from "papaparse";
import _ from "lodash";
import { Upload, message, Button, Table, Input } from "antd";
import { UploadOutlined } from "@ant-design/icons";
export default function Home() {
const [columns, setColumn] = useState([]);
const [baseData, setBaseData] = useState([]);
const [filterTable, setFilterTable] = useState(null);
const props = {
name: "file",
accept: ".txt, .csv",
headers: {
authorization: "authorization-text",
},
async onChange(info) {
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
if (info.file.status === "done") {
const texts = await info.file.originFileObj.text();
const results = parse(texts, {
header: true
});
const col = _.keys(results.data[0]);
const customCol = _.map(col, (value) => ({
title: value,
dataIndex: value,
key: value.toLowerCase(),
}));
const data = results.data;
console.log({ customCol });
console.log({ data });
setColumn(customCol);
setBaseData(data);
message.success(`${info.file.name} file uploaded successfully`);
} else if (info.file.status === "error") {
message.error(`${info.file.name} file upload failed.`);
}
},
};
return (
<div>
<main>
<Upload {...props}>
<Button icon={<UploadOutlined />}>Click to Upload</Button>
</Upload>
<Table pagination={false} columns={columns} dataSource={filterTable == null ? baseData : filterTable} />
</main>
</div>
);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Here’s the table props:
export interface TableProps < RecordType > extends Omit < RcTableProps < RecordType > , 'transformColumns' | 'internalHooks' | 'internalRefs' | 'data' | 'columns' | 'scroll' | 'emptyText' > {
dropdownPrefixCls ? : string;
dataSource ? : RcTableProps < RecordType > ['data'];
columns ? : ColumnsType < RecordType > ;
pagination ? : false | TablePaginationConfig;
loading ? : boolean | SpinProps;
size ? : SizeType;
bordered ? : boolean;
locale ? : TableLocale;
onChange ? : (pagination: TablePaginationConfig, filters: Record < string, (Key | boolean)[] | null > , sorter: SorterResult < RecordType > | SorterResult < RecordType > [], extra: TableCurrentDataSource < RecordType > ) => void;
rowSelection ? : TableRowSelection < RecordType > ;
getPopupContainer ? : GetPopupContainer;
scroll ? : RcTableProps < RecordType > ['scroll'] & {
scrollToFirstRowOnChange ? : boolean;
};
sortDirections ? : SortOrder[];
showSorterTooltip ? : boolean;
}
export interface TableProps < RecordType = unknown > extends LegacyExpandableProps < RecordType > {
prefixCls ? : string;
className ? : string;
style ? : React.CSSProperties;
children ? : React.ReactNode;
data ? : RecordType[];
columns ? : ColumnsType < RecordType > ;
rowKey ? : string | GetRowKey < RecordType > ;
}
What could be the problem?
provigil schedule – vigilpr.com provigil 100mg
http://cialisay.com cialis drug
buy accutane online from europe – accutane otc accutane australia buy
https://wardenafil.com levitra 20 mg india price
amoxicillin without a doctor – gnamoxicill generic amoxil
vardenafil 20 mg online – vardenafil online sale order vardenafil online canada
http://canadianvolk.com prescription costs without insurance
ivermectin 6 mg tablets – stromectol australia stromectol for humans
online pharmacy china – can you buy cialis over the counter in canada brand cialis prices
stromectol 6 mg dosage – ivermectin 1 cream ivermectin pill cost
accutane online canada pharmacy – accutane pharmacy buy brand name accutane online
http://ycialisy.com generic name for cialis
buy lyrica mexico – canadian pharmacy no prescription canadian pharmacy phone number
generic name for amoxil – buy amoxicillin noscript amoxicillin pneumonia
http://prescriptionhim.com/ generic viagra without doctor visit
https://himshairloss.com/ generic finasteride 1mg
sildenafil citrate 100 – sildenafil fast shipping can i buy viagra over the counter australia
cialis 20mg cost canada – cialis 20mg canada cialis professional
http://essinreceta.com comprar sildenafil espaГ±a
ivermectin 12mg online – stromectol tablets for sale ivermectin online pharmacy
prednisone 20 mg generic – how to get prednisone mail order prednisone
modafinil dosage – site provigil a drug
https://stromectolhumans.com/ ivermectin paste for humans
https://viagraxyu.com viagra from canada
https://iwermectin.com/ ivermectin over counter
buy generic azithromycin 500mg – can you buy zithromax online zithromax buy canada
order lasix without a prescription – furosemide 100 mg ordering furosemide
buy clomid – buy clomiphene online clomid over the counter
https://ivermectinovercounter.com/ stromectol
https://ivermectineffects.com what is stromectol used for
what to do if someone is telling people that i have hiv medical practice
where to buy ivermectin https://ivermectinhome.com
how to take levitra https://levitrair.com levitra 20 pills
http://zithrozpack.com/ zithromax over counter
home first aid kit single health insurance
ivermectin cream https://ivermectinhome.com
asthma academic issues what does your blood pressure do when having a heart attack’
ivermectin stromectol 3 mg tablet https://ivermectinhome.com
ivermectin for sale http://stromectolus.com stromectol
https://albuterolotc.com/ ventolin price usa
pope francis forgives pedophile priest with hiv who raped 30 children what veggie kills high blood pressure
stromectol https://ivermectinhome.com
stromectol http://stromectolus.com stromectol
who pays for single payer health care according to statistics, which teen population is most in danger of getting hiv or aids
buy ivermectin liquid https://ivermectinhome.com
ivermectin tablets amazon http://ivermcov.com/# ivermectin for humans amazon
javascript-help.li vs discount over the counter medications http://pharmvolk.com walgreens pharmacy prescription history
home remedies for blood pressure https://ventolinhfaer.com/ ventolin inhaler cost usa
aca health insurance medication search by name
ivermrctin tablets https://ivermectinhome.com
javascript-help.li reviewed ivermectin http://ivermectini.com ivermectin pills otc
doxycycline 50 – 200 mg doxycycline doxycycline 100mg buy online
spinal arthritis http://ventolinhfaer.com albuterol for sale
from which survey data set can i do hiv reseach ? generic ivermectin https://iveramectin.com can humans take ivermectin paste
acv asthma http://kamagraxy.com kamagra india
canadian pharmacy viagra no prescription https://viagrob.com female viagra prank
TypeError: (data || []).forEach is not a function – JavaScript Help buy generic cialis online india http://cialistwenty.com cheapest place to buy cialis
buy prednisone with paypal – buy prednisone no prescription pharmacy online prednisone
lasix online purchase – buy furosemide 20 mg tabs over the counter lasix pills
cytotec tablet – cytotech buy cytotec
zithromax z pak dosing https://azithrozpack.com amoxicillin buy online
http://stromectolhome.com – stromectol
where to buy stromectol online https://ivermectin1.com/ stromectol cost
letter writing services – teach me how to write an essay buy my essay
http://ivrmectin.com – ivermectin
http://viwithout.com – viagra u.s.a
compare prices viagra – 5 mg cialis cialis 5mg online price
fexofenadine hcl – https://allergyd.com
plaquenil and weight gain – hydroxychloroquine for rheumatoid arthritis prednisone brand name australia
https://stromectolforte.com/# ivermectina dosis en humanos
ivermectin for humans http://stromectolforte.com/ ivermectin oral solution ivermectin 1 cream
stromectol order https://stromectoloff.com/ stromectol dk
ivermectina uso umano prezzo http://stromectolforte.com/ ivermectin for humans to buy now dosage ivermectin tablets over counter
aaa health insurance http://cialisay.com – cialis generic online
ivermectin 1% – buy stromectol for humans australia stromectol over the counter
ivermectin drug – stromectol pills stromectol coronavirus
best casino online – online slots for real money casino game
women viagra https://www.viagwdp.com/# viagra buy online where can you buy viagra over the counter in uk
help with writing a paper – write me a essay paperwriter
where to get female viagra over the counter http://www.viagwdp.com/ viagra pills for men female viagra buy australia
where can i get accutane cheap – buy accutane without prescription accutane cost online
Lisinopril schedule rx pharmacy one source
ivermectin 0.5% – ivermectin 3mg tablet ivermectin drug
slots online – best casino games online casino real money us
cialis soft tabs buy cialis shipment to russia
walgreen cialis price viragecialis
best writing service reviews letter writing service
writing essays help college essay writer
best research paper writing services research paper writing services in india
dissertation format dissertation help service
cleopatra essay ou craigslist essay writing
upsc essay question paper 2013 essay on newspaper in modern world
trinity university san antonio essay jim thorpe essay
plaquenil 400mg price – plaquenil oral order valtrex 1000mg online cheap
Good to learn 🙂
sildalis canada – purchase propecia generic order glucophage online cheap
order ampicillin 500mg for sale – flagyl 200mg pill purchase hydroxychloroquine for sale
purchase plaquenil generic – brand plaquenil order hydroxychloroquine 400mg without prescription
tadalafil blood pressure https://cialisusdc.com/
canada generic tadalafil where to buy generic cialis online safely
where to buy generic cialis online safely where to buy generic cialis online safely
cheap cialis pills for sale what is tadalafil
5mg buspar