You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Redux Toolkit Query轮询引发无数据变更时组件重复渲染问题求助

数据未变更但轮询时组件重复渲染问题

数据本身没有变化,但每次轮询请求执行时,组件仍会出现重渲染情况。我查资料了解到selectFromResult属性可以仅获取数据本身,而非isFetching这类额外状态属性,以下是我的相关代码:

API Slice 中的查询定义

getNotification: builder.query<GetNotificationsResponse, GetNotificationsRequest>({
      query: ({ page, limit }) => ({
        url: `notifications?page=${page}&limit=${limit}`,
        method: 'GET',
      }),
    }),

组件内使用轮询与selectFromResult的实现

const result = useGetNotificationQuery(
    {
      page: 1,
      limit: 10,
    },
    {
      pollingInterval: 1000,
      selectFromResult: data => data.data,
    },
  );

内容的提问来源于stack exchange,提问作者AlmaG3st

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 19:01:17