material-table
material-table copied to clipboard
Setting remote data to state data
https://material-table.com/#/docs/features/remote-data Following this example, i wish to set the result.data to the state.data so that if i delete a row, it will use the state.data array
<MaterialTable
columns={state.columns}
data={query =>
new Promise((resolve, reject) => {
let url = 'http://localhost:8080/api/clients';
fetch(url)
.then(response => response.json())
.then(result => {
setState({...state, data: result.data });
console.log(state);
resolve({
data: state.data,
page: result.page - 1,
totalCount: result.total,
})
});
})
I cannot figure out though why the state.data is still empty even after calling setState.
Hey @chitgoks what was your solution to this? i am facing a similar issue and cant figure out why the state object is empty.