You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(InfiniteListItems): Fix types to support non-array based ApiResult objects (#97690)
Before we were hard-coding the assumption about the response shape:
```
# before
const loadedRows = deduplicateItems(
data ? data.pages.flatMap(result => result[0]) : []
);
```
This was assuming that `result` is an ApiResult, which is a tuple.
Now we have better types! These let us extract the list of things from
inside the ApiResult first, it's just basically the do-it-yourself
method, just implement: `(page: Response[]) => ListItem[];`
Example
So if you have some data like this:
```
const fromTheApi: ReplayListResponse = {data: [{replayId: 123}, {replayId: 234}]};
const response: ApiResult<ReplayListResponse> = [fromTheApi, status, rawResponse];
```
it's possible to extract out the `[{replayId: 123}, {replayId: 234}]`
from inside the ApiResult now with `deduplicateItems={pages =>
uniqBy(pages.flatMap(page => page[0].data), 'replayId')}`
0 commit comments