score:1
Just put <TableCell />
in to the <TableRow />
for example
import { Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material';
export default function Untitled() {
const items = GetItems() //get items from some where...
return (
<Table>
<TableHead>
<TableRow> // <--- I mean this section
<TableCell> ID </TableCell>
<TableCell> name </TableCell>
<TableCell> last name </TableCell>
</TableRow>
</TableHead>
<TableBody>
{
items.map((item, key) => (
<TableRow key={key}> // <--- I mean this section
<TableCell> {item.id} </TableCell>
<TableCell> {item.name} </TableCell>
<TableCell> {item.last_name} </TableCell>
</TableRow>
))
}
</TableBody>
</Table>
);
}
score:2
I've had this error come up because of mistakes elsewhere in my list.
For example @Sag1v has <tbody>
instead of </tbody>
to close the body of his list and I bet that is causing the error.
score:4
Mistakenly, I had tbody
inside thead
(1)
<thead>
...
<tbody>
...
</tbody>
</thead>
instead of (2)
<thead>
...
</thead>
<tbody>
...
</tbody>
Changing to (2) solved my problem.
score:80
Well th
should be nested under a tr
not a thead
. Docs
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
score:142
The only direct children allowed for thead
are tr
elements, not th
.
<table>
<thead>
<tr>
<th />
</tr>
</thead>
...
</table>
Source: stackoverflow.com
Related Query
- REACT ERROR <th> cannot appear as a child of <thead>. See (unknown) > thead > th
- How do I wrap a React component that returns multiple table rows and avoid the "<tr> cannot appear as a child of <div>" error?
- React: <tr> cannot appear as a child of <td>. See Comment > td > tr
- React <div> cannot appear as a child of <tr> Warning
- <span> cannot appear as a child of <select> in react
- <thead> cannot appear as a child of <div>. when using react material-ui/core
- I can see data in console but CANNOT grab it. parent to child callback in React
- Semantic UI React : <thead> cannot appear as a child of <tbody>
- react error unknown : TypeError: Cannot read properties of undefined
- How to resolve the validateDOMNesting(...): <form> cannot appear as a descendant of <form> error React JS
- React Material UI error <div> cannot appear as a descendant of <p>
- Objects are not valid as a React child - Cannot resolve error
- Cannot find namespace 'ctx' error when creating Context with react - typescript
- React: validateDOMNesting: #text cannot appear as a child of <tr>
- Cannot convert object to primitive value error in react application?
- React Native Error Cannot find module 'metro-config/src/defaults/blacklist'
- validateDOMNesting(...): <tr> cannot appear as a child of <div>
- React Router Error - Cannot GET [Page Name]
- Cannot read property 'refs' of null react error react js
- How to fix Warning: validateDOMNesting(...): <div> cannot appear as a child of <tbody>
- <input> cannot appear as a child of <tr>
- React: how to use child FormItem components without getting Warning: validateDOMNesting: <form> cannot appear as a descendant of <form>
- Warning: validateDOMNesting(...): <div> cannot appear as a child of <tbody>
- Error : Cannot read property fetch. Using jest-expo with react native
- React.Children.only expected to receive a single React element child error
- Cryptic React error "unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering."
- Objects are not valid as a React child getting error when adding div?
- Cannot call a class as a function, React router show error in console if i use es6 format
- How to fix validateDOMNesting(...): <td> cannot appear as a child of <tbody>. and Each child in a list should have a unique "key" prop
- React --> Warning: validateDOMNesting(...): <p> cannot appear as a descendant of <p>
More Query from same tag
- Why function has to be called twice to update hook state?
- this.state is undefined during onPress event in react native
- what is difference between using and not using call method in redux saga?
- How to get key value based on array name?
- How can I use React Router to change routes from within a component that is also Routed in the Main App.js component?
- Authenticated navigation in React
- Axios data is breaking the request
- Why is my react component not updating with state updates?
- Making hex 3-digit converts it to 6-digits while using `rgb-hex` library as an input in React JS?
- Using mapStateToProps in Redux
- Compare two arrays values, and populate if no match
- React.JS video player bug
- React with Fluent UI Form onChange not working (very simple code)
- Update state and call parent onChange handler simultaneously from child component during onChange event
- What type to use for imported svg icon from an .svg file in React with Typescript?
- Does a component need to disconnect from the socket io server after unmounting?
- react - select causing page to scroll down
- Node events.js:167 throw er; // Unhandled 'error' event
- React display condition
- ChartJs chart in typescript: Object is possibly undefined in useEffect
- TypeError: Cannot read properties of undefined (reading 'requestContent')
- When flipping a card with css the backside shows but it is not usable
- Prevent trigger focus event when clicking
- Can't seem to display image using require or uri on React Native! What am I doing wrong?
- Add new child to nested state object
- 2 level nested routing in react-router doesn't route properly the first level
- React Jest: How to mock Service?
- Why Firebase user is not authenticated anymore when refreshing?
- I have a problem importing a Bit compiler. How can I resolve the following error?
- How to show in a list, visible markers in the google map with React