在 RTK 查询中按顺序执行多个突变的推荐方法是什么?

dan*_*boy 5 rtk-query

建议使用哪种方式使用 RTK 查询按顺序执行多个突变?

  const [
    updateProfile, 
  ] = useUpdateProfileMutation();

  const [
    updatePost,
  ] = useUpdatePostMutation();


  const performMutipleMuations = async () => {
    const data= await updateProfile(newData);
    await updatePost(data);
  };



Run Code Online (Sandbox Code Playgroud)

dan*_*boy 4

最终使用unwrap成功了。

  const performMutipleMuations = async () => {
    const data= await updateProfile(newData).unwrap();
    await updatePost(data).unwrap();
  }
Run Code Online (Sandbox Code Playgroud)