我正在尝试清除缓存,以便从新用户那里获取数据,而不是从注销的用户那里获取数据。
在文档中,Apollo建议使用clearStore()
,但似乎不起作用。
我尝试过这种方式:
handleLogout = () => {
const { client } = this.props;
localStorage.clear();
client.clearStore().then(() => {
history.push('/login')
})
clearStore()
返回Promise,所以我这样做了,我也尝试调用该函数,但还是一样
答案 0 :(得分:0)
您可以使用以下方法调用缓存存储区并进行重置:
handleLogout = () => {
const { client } = this.props;
client.cache.reset().then(() => {
history.push('/login')
})