【发布时间】:2022-01-21 02:35:09
【问题描述】:
我是阿波罗的新手。我正在尝试创建加载微调器。我正在使用class components,但我不能使用钩子。获取class components 数据的唯一方法是通过client.query() 问题是加载状态始终为假。
const client = new ApolloClient({
uri: '/express',
cache: new InMemoryCache(),
defaultOptions: {
query: {
fetchPolicy: 'network-only',
notifyOnNetworkStatusChange: 'true',
},
},
})
export const fetchProducts = () => {
return client
.query({
notifyOnNetworkStatusChange: true,
fetchPolicy: 'network-only',
query: PRODUCT_QUERY,
})
.then((result) => {
console.log(result.loading + '<-- spinner')
return result
})
}
@apollo/client: "^3.5.6" 反应:“^17.0.2”
【问题讨论】: