GriddleGriddle / Griddle

Simple Grid Component written in React
http://griddlegriddle.github.io/Griddle/
MIT License
2.5k stars 378 forks source link

How to tell Griddle that external data is loading ? #770

Open anujgakhar opened 7 years ago

anujgakhar commented 7 years ago

Griddle version

1.9

Expected Behavior

To show Loading state when external data is loading on Next or Previous button click

Actual Behavior

I see a 'No results found' message when the call is in flight because the current dataLoadingSelector just checks for existence of data

Steps to reproduce

Whenever I hook in the onNext and onPrevious events to fetch external data

I've written my own plugin that changes some of the Pagination components and buttons and it works well. However, when I click 'Next' or 'Previous', instead of seeing a 'Loading' state, I see a 'NoResults' state in the Table. Is there an easy way to tell Griddle that external data is loading so it can show the correct state ?

dahlbyk commented 7 years ago

I would expect you could dispatch GRIDDLE_UPDATE_STATE (actions.updateState) with { data: null } to switch back to Loading. Or there's no reason you couldn't use reducers for the pagination action types to set/unset an explicit Loading state.

anujgakhar commented 7 years ago

@dahlbyk thanks for the reply, you got an example of this? I can't seem to get it working. If I dispatch an actions.updateState onClick of NextButton, there's a runtime error at line 60 of dataUtils.js

dahlbyk commented 7 years ago

I do not have a working example handy, no. If you could put together a basic repro I would be glad to take a closer look.