RTK:如何在突变成功后运行重新获取

问题描述 投票:0回答:1

我想在变异成功后调用 refetch 函数:

 const [joinTeam ] = useJoinTeamMutation();
 const { refetch } = useGetTeam(slugName);

我尝试这样做:

leaveTeam().then((res: any) => {
     if (!res.error) {
          refetch();
     }
});

但这会导致错误:

Cannot refetch a query that has not been started yet.

react-redux redux-toolkit rtk-query
1个回答
0
投票

这是使用标签内置的,无需承诺检查文档自动重新获取

© www.soinside.com 2019 - 2024. All rights reserved.