Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useAntTable 和 useAsync 同时使用的问题 #141

Closed
Nokecy opened this issue Nov 8, 2019 · 3 comments
Closed

useAntTable 和 useAsync 同时使用的问题 #141

Nokecy opened this issue Nov 8, 2019 · 3 comments

Comments

@Nokecy
Copy link

Nokecy commented Nov 8, 2019

在useAsync onSuccess 中调用useAntTable的submit方法不会重新刷新表格。
用例是:使用useAsync新增一条数据后需要刷新表格数据。
https://codesandbox.io/s/hooks-demo-u3l66

@brickspert
Copy link
Collaborator

在useAsync onSuccess 中调用useAntTable的submit方法不会重新刷新表格。
用例是:使用useAsync新增一条数据后需要刷新表格数据。
https://codesandbox.io/s/hooks-demo-u3l66

把 submit 放到 useAsync 的 deps 中就可以了。

  const { loading, run } = useAsync(
    () => {},
    [submit, hide],
    {
      manual: true,
      onSuccess: () => {
        submit();
        hide();
      }
    }
  );

或者你可以这样写

run().then(()=>{
        submit();
        hide();
});

@brickspert
Copy link
Collaborator

有问题再 open 哦。

@Nokecy
Copy link
Author

Nokecy commented Nov 9, 2019

run().then(()=>{
        submit();
        hide();
});

这种方法可行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants