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

Setting remote data to state data

Open chitgoks opened this issue 7 years ago • 1 comments

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.

chitgoks avatar Oct 28 '19 09:10 chitgoks

Hey @chitgoks what was your solution to this? i am facing a similar issue and cant figure out why the state object is empty.

karanness86 avatar Dec 18 '19 19:12 karanness86