【问题标题】:React Native & RTK Query - IsLoading on refetch methodReact Native & RTK Query - IsLoading on refetch 方法
【发布时间】:2022-01-17 07:40:11
【问题描述】:

为什么当我在下面的代码中使用refetch 方法时,isLoading 值在提取期间不会在true 上返回?

const [matchFilterSelected, setMatchFilterSelected] = useState('explorer')

// Query declaration
const {
  data: matches,
  refetch,
  error: matchesError,
  isLoading: matchesIsLoading,
} = useFetchMatchesQuery(matchFilterSelected)

// Callback function from onPress event
const filterSelectedChanged = (matchesType) => {
  if (matchesType && matchesType !== matchFilterSelected) {
    setMatchFilterSelected(matchesType)
    refetch()
  }
}

【问题讨论】:

    标签: react-native redux rtk-query


    【解决方案1】:

    不,isLoading 仅在初始加载时为真。您可能想使用 isFetching - 显示实际活动。

    【讨论】:

    • 非常感谢您的快速回复,一切正常 :)
    猜你喜欢
    • 2022-01-13
    • 2023-02-09
    • 2022-01-15
    • 2023-02-10
    • 2021-08-31
    • 2023-01-21
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多