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

isLoading doesn't work properly

Open jakeleventhal opened this issue 7 years ago • 2 comments

Describe the bug If you use the isLoading prop in conjunction with data, the table crashes and says the data can't be null

To Reproduce Steps to reproduce the behavior:

  1. Make a table with data={tableDataVar}
  2. Set the isLoading prop to isLoading={!tableDataVar}
  3. An error appears saying that data must not be null

Expected behavior The error should not appear if the isLoading value is set to true

jakeleventhal avatar May 20 '19 23:05 jakeleventhal

Set your state’s data prop to an empty array. You have a table in your UI expecting it to have data at some point in the form of an array, if the array is empty material-table shows your users a nice no data message which you can also override with localization. For state expecting an array of values generally I have seen you set it to an empty array with initialState.

priemd avatar May 22 '19 02:05 priemd

Hi @jakeleventhal ,

This is not a bug. You should set a empty array to data. If you want to loading animation you can use data.length === 0 or use another flag on state.

mbrn avatar May 27 '19 04:05 mbrn