在graphql中,每次更新“数据”时都执行“加载”工作吗?
现在,即使数据发生变化,第一次加载为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
});
答案 0 :(得分:0)
来自docs:
useQuery挂钩的结果对象通过
networkStatus
属性提供有关查询状态的详细信息。为了利用这些信息,我们需要将notifyOnNetworkStatusChange选项设置为true,以便我们的查询组件在进行重新获取时重新呈现
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!';
您可以在source
中找到所有值