I am using Material Table for displaying table data.
Using onRowAdd, I am able to add a new row but the page is not refershing. It reloads and get stuck then I have to reload it again.
newData =>
new Promise(resolve => {
setTimeout(() => {
resolve();
this.setState(prevState => {
this.props.saveSetting(newData, this.state.resource, "generalmessage.successMessage");
const data = [...prevState.data];
return { ...prevState, data };
});
}, 600);
})
Save Setting is the function that I am calling in sagas.
I am not able to understand what I am doing wrong here. Please guide me in this.
I'm not sure if you're using useState in your component.
Anyway, I did my onRowAdd this way and it's working:
onRowAdd: (newRow) =>
new Promise((resolve, reject) => {
setTableData([...tableData, newRow]);
setTimeout(() => resolve(), 500);
})
Hope this helps