material-table icon indicating copy to clipboard operation
material-table copied to clipboard

App freezes after deleting some rows

Open medi11 opened this issue 6 years ago • 10 comments

`import React, { useState } from "react"; import MaterialTable, { MTableToolbar } from "material-table"; import PrintIcon from '@material-ui/icons/Print'; import { Button } from "@material-ui/core"; import { useStyles } from "../assets/jss/PaginatedTableWrapper.styles"; import { icons } from "./icons";

export default function PaginatedTableWrapper({ tableColumns, title, color, shadow, icon }) { console.log("hi there"); const [columns, setColumns] = useState(tableColumns); const [data, setData] = useState([ { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, { society: 'Zerya Betül', lastName: 'Baran', firstName: 2017, phone: "0554-25-74-36" }, ]); const classes = useStyles();

const customToolbar = (props) => {
	return (
		<>
			<div className={classes.iconTableWrapper} style={{ backgroundColor: color, boxShadow: shadow }}>
				{
					icon
				}
			</div>
			<MTableToolbar {...props} />
		</>
	);
};


return (
	<div className={classes.tableWrapper}>
		<MaterialTable
			title={title}
			icons={icons}
			columns={columns.slice(0, columns.length - 1)}
			data={data}
			actions={columns[columns.length - 1]}
			options={{
				actionsColumnIndex: -1,
				pageSize: 5,
				pageSizeOptions: [],
				exportButton: true
			}}
			localization={{
				body: {
					emptyDataSourceMessage: "Pas d'enregistreent à afficher",
					addTooltip: 'Ajouter',
					deleteTooltip: 'Supprimer',
					editTooltip: 'Editer',
					filterRow: {
						filterTooltip: 'Filtrer'
					},
					editRow: {
						deleteText: 'Voulez-vous supprimer cette ligne?',
						cancelTooltip: 'Annuler',
						saveTooltip: 'Confirmer'
					}
				},
				header: {
					actions: 'Actions'
				},
				pagination: {
					labelDisplayedRows: '{from}-{to} de {count}',
					labelRowsSelect: 'lignes',
					labelRowsPerPage: 'lignes par page:',
					firstAriaLabel: 'Première page',
					firstTooltip: 'Première page',
					previousAriaLabel: 'Page précédente',
					previousTooltip: 'Page précédente',
					nextAriaLabel: 'Page suivante',
					nextTooltip: 'Page suivante',
					lastAriaLabel: 'Dernière page',
					lastTooltip: 'Dernière page'
				},
				toolbar: {
					addRemoveColumns: 'Ajouter ou supprimer des colonnes',
					nRowsSelected: '{0} ligne(s) sélectionée(s)',
					showColumnsTitle: 'Voir les colonnes',
					showColumnsAriaLabel: 'Voir les colonnes',
					exportTitle: 'Exporter',
					exportAriaLabel: 'Exporter',
					exportName: 'Exporter en Excel',
					searchTooltip: 'Chercher',
					searchPlaceholder: 'Chercher'
				}
			}}
			components={{
				Toolbar: (props) => customToolbar(props),
			}}
			editable={{
				onRowDelete: oldData =>
					new Promise((resolve, reject) => {
						setTimeout(() => {
							const dataDelete = [...data];
							const index = oldData.tableData.id;
							dataDelete.splice(index, 1);
							setData([...dataDelete]);

							resolve();
						}, 1000);
					}),
			}}
		/>
		<div className={classes.buttonsWrapper}>
			<Button variant="contained" className={classes.button}>
				<PrintIcon className={classes.printIcon} />
				Imprimer
			</Button>
		</div>
	</div>
);

}`

medi11 avatar Aug 31 '20 21:08 medi11

Experiencing the same issue. There is something broken with the delete operation. You can reproduce the issue using https://material-table.com/#/docs/features/editable.

matis-dk avatar Sep 01 '20 10:09 matis-dk

Experiencing the same issue. There is something broken with the delete operation. You can reproduce the issue using https://material-table.com/#/docs/features/editable.

I uninstalled the latest version and installed 1.68.0 and it works fine with me.

medi11 avatar Sep 01 '20 10:09 medi11

Unfortunately 1.68.0 has other critical bugs (crashes with onBulkUpdate) and API has changed since 1.67.0 so this is quite annoying.

cdruck avatar Sep 02 '20 09:09 cdruck

exactly..am looking for options other than material table if it lingers more than a week now ...

bvenkatr10 avatar Sep 07 '20 17:09 bvenkatr10

I have the same problem with the onRowUpdate event: the entire page completely freezes after some updates (4-5). I switched to version 1.67.1 and it works stable for me.

Andemki avatar Sep 07 '20 17:09 Andemki

@Andemki Thanks for letting us know of your solution, helped me not making the same money for more time (less per hour) by rewriting on another table library.

ghost avatar Sep 09 '20 01:09 ghost

IS this problem due to the infinty loop and still present in 1.69.1 or is this connected to the deletion of the rows themselves?

Domino987 avatar Oct 02 '20 23:10 Domino987

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Jan 01 '21 02:01 stale[bot]

Unfortunately mbrn is inactive and not merging PR's. Use the official community fork @material-table/core instead.

peacechen avatar Jan 06 '21 07:01 peacechen

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Apr 06 '21 07:04 stale[bot]