Having a data-filled table, I am looking to implement smooth transitions when adding or deleting an item. This is a ReactJS project utilizing Material-UI.
The desired effect is similar to the one demonstrated in their example. While they use a List component, my implementation involves a table. Here's a snippet of the code:
<TableBody>
<TransitionGroup component={null} id="ffff">
{(data?.maintenanceRequests || []).map((form) => (
<Collapse key={form.id} component={TableRow}>
<TableCell>{form.building}</TableCell>
<TableCell>{form.dueDate ? form.dueDate : '-'}</TableCell>
<TableCell align="right">
<IconButton component={Link} to={`request/${form.id}`}>
<EditIcon />
</IconButton>
<IconButton onClick={() => deleteReq({ variables: { deleteMaintenanceRequestId: form.id }, refetchQueries: [{ query: GET_MAINTENANCE_REQUESTS }] })}>
<DeleteIcon />
</IconButton>
</TableCell>
</Collapse>
))}
</TransitionGroup>
</TableBody>
Using this code triggers warnings such as:
Warning: validateDOMNesting(...): <td> cannot appear as a child of <div>.
And Warning: validateDOMNesting(...): <div> cannot appear as a child of <tr>.
I have already specified the components that and should wrap. Upon inspecting the element, I noticed that the TransitionGroup component adds two nested div elements, hence the warnings. The challenge now lies in resolving these issues.