gpt4 book ai didi

Using 'select' option in react query paginated queries to filter by category(在Reaction Query分页查询中使用‘SELECT’选项按类别进行筛选)

转载 作者:bug小助手 更新时间:2023-10-25 19:54:07 25 4
gpt4 key购买 nike



I have made a meme generator app and the following is the path for client to select a template:

我做了一个表情包生成器APP,下面是客户端选择模板的路径:


`//localhost:3001/select-template?page=${pageNumber}`.

Fetching the data:

获取数据:


const { data, isLoading, isFetching } = useQuery(
["images", pageNumber],
() => fetchImages(pageNumber),
{
keepPreviousData: true,
refetchOnWindowFocus: false,
select: 'Need help with this'
}
);

The response from the api is in the following format:

本接口的返回格式如下:


{
all_Images: (10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
page: "0"
totalItems: 18
totalPages: 2
};

This is the first time I am using React query. What I would like to do is:

这是我第一次使用Reaction Query。我想做的是:


Utilising the 'select' option and be able to use the js filter() method to display images based on the category selected from a dropdown box.

使用‘SELECT’选项,并能够使用js Filter()方法根据从下拉框中选择的类别显示图像。


Here is an example code to give you an idea of what I want to achieve:

下面是一个示例代码,让您了解我想要实现的目标:


select: (images) => images.filter((img) => img.category.includes(cat)).

I will be very grateful to whoever takes the time to assist me with this.

我将非常感谢谁抽出时间来帮助我做这件事。


更多回答

What result did you get? Show debugging details

你得到了什么结果?显示调试详细信息

@LinDu So this is what I tried doing: select: (data) => data.all_Images.filter((img) => img.category.includes(cat)); This however changes the response immediately to render only the first page.

@lindu,所以这就是我尝试做的:SELECT:(Data)=>data.all_Images.Filter((Img)=>img.categy.includes(Cat));但是这会立即更改响应以仅呈现第一个页面。

优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com