Answer the question
In order to leave comments, you need to log in
How to fix error when rendering components in map?
I wrote components for a table, and I'm trying to display in the map functions, but I get this error:
Objects are not valid as a React child (found: object with keys {scope, children}). If you meant to render a collection of children, use an array instead.
return (
<Table>
<TableHead columns={columns} />
<TableBody>
{data.map((item) => {
return (
<TableRow>
<TableHeading scope="row">{item.id}</TableHeading>
<TableCell>{item.name}</TableCell>
<TableCell>{item.price}</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
);
};
Answer the question
In order to leave comments, you need to log in
found an error, it was not here at all. In the TableHeading component, I forgot to specify the {children} destructuring. Sorry.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question