feat: add state invalidation to BasePaginator class#1734
feat: add state invalidation to BasePaginator class#1734arnautov-anton wants to merge 1 commit intomasterfrom
Conversation
|
Size Change: +350 B (+0.09%) Total Size: 381 kB 📦 View Changed
|
2312c6f to
836b577
Compare
836b577 to
bd6d38e
Compare
bd6d38e to
2e509fb
Compare
| if (!this.canExecuteQuery(direction)) return; | ||
| const isFirstPage = typeof this.items === 'undefined'; | ||
| if (isFirstPage) { | ||
| this.state.next(this.getStateBeforeFirstQuery()); |
There was a problem hiding this comment.
Removing this is potentially breaking
There was a problem hiding this comment.
As this is setting state before the query is executed. This is a hook that can be used by integrators to adjust the state before the first query.
There was a problem hiding this comment.
State before the first query should always be initialState unless invalidated. When invalidated and re-fetched, the state is kept until there's something to replace it with to prevent the data -> no data -> new data UI blinking.
There was a problem hiding this comment.
Ok, then we should also remove getStateBeforeFirstQuery method, because in this PR it does not make anymore sense - it is called before the first query but not applied to the state before the first query.
Description of the changes, What, Why and How?
Adds state invalidation logic to a
BasePaginatorclass, adjusts types. Super-simplifiedreact-queryfeature (invalidateQueries).Ref: GetStream/stream-chat-react#3173