Skip to content

Commit 8be3c60

Browse files
authored
Use higher order function (array) in code example
1 parent 976fdb7 commit 8be3c60

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/src/pages/guides/infinite-queries.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,10 @@ queryClient.setQueryData('projects', data => ({
158158
Manually removing a single value from an individual page:
159159

160160
```js
161-
const newPagesArray = []
162-
oldPagesArray?.pages.forEach(page => {
163-
const newData = page.filter(val => val.id !== updatedId)
164-
newPagesArray.push(newData)
165-
})
161+
const newPagesArray = oldPagesArray?.pages.map((page) =>
162+
page.filter((val) => val.id !== updatedId)
163+
)
164+
166165
queryClient.setQueryData('projects', data => ({
167166
pages: newPagesArray,
168167
pageParams: data.pageParams,

0 commit comments

Comments
 (0)