I'm trying to upload csv file and display it on Table.
So I'm trying to display info data on DataTable and I got an error info[0].slice is not a function.
So I tried to comment info[0].slice this out . then it works but I can't get the column.label when i uncomment info[0].slice after i upload a file.
I don't know what happens behind it so i can't figure out .
So How can i make columns work ??
my code is like this :
const [info, setInfo] = useState([{}]);
const handleOnDrop = droppedItems => {
const infos = droppedItems.map(item => item.data);
setInfo([...infos]);
};
const DataTable = ({ info }) => {
// const columns = []; //this is what i was trying to do to make columns work afterwards.
const columns = info[0]
.slice(undefined)
.map(inf => [{ id: inf, label: inf, minWidth: 170, align: "left" }]);
<TableRow>
{columns.map(column => (
<TableCell
key={column.id}
align={column.align}
style={{ minWidth: column.minWidth }}
>
<select name="" id="">
<option value="3" selected>
</option>
<option value="0">x</option>
<option value="1">y</option>
<option value="2">label</option>
</select>{" "}
<p>{column.label}</p>
</TableCell>

slice(undefined)?slice(undefined)info[0]before slice?(4) ["age ", "name", "phone", "city"]that is from a csv file (it's console results)