Reactjs 在图ql中,对';装载';每次更新时工作';数据';?

Reactjs 在图ql中,对';装载';每次更新时工作';数据';?,reactjs,graphql,Reactjs,Graphql,在graphql中,每次更新“数据”时“加载”是否起作用 现在,当第一次加载true和下一次加载true时,尽管数据发生了变化,但他始终为false const {loading, error, data, refetch, called } = useQuery(GET_COOKIES, { context: { headers: {"x-request-shop-id": props.currentStore ? props.currentStore.id : ""}}

在graphql中,每次更新“数据”时“加载”是否起作用

现在,当第一次加载true和下一次加载true时,尽管数据发生了变化,但他始终为false

const {loading, error, data, refetch, called } = useQuery(GET_COOKIES, {

    context: {
      headers: {"x-request-shop-id": props.currentStore ? props.currentStore.id : ""}},
    skip: !props.currentStore.id
  });
从:

useQuery钩子的结果对象通过
networkStatus
属性提供有关查询状态的细粒度信息。为了利用这些信息,我们需要将notifyOnNetworkStatusChange选项设置为true,以便查询组件在执行refetch时重新呈现

您可以在中找到所有值

const {loading, error, data, refetch, called, networkStatus } = useQuery(GET_COOKIES, {

    context: {
      headers: {"x-request-shop-id": props.currentStore ? props.currentStore.id : ""}},
    skip: !props.currentStore.id,
    notifyOnNetworkStatusChange: true,
  });

  if (networkStatus === 4) return 'Refetching!';