-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: useAsync add params & autoCancel #112
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/umijs/hooks/n3yrjrb58 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should update the doc~
} | ||
if (runCount === count.current) { | ||
if (!autoCancel || runCount === count.current) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is best to add a note here.
because it‘s consistent with the above conditions.
it is easy to think that it is redundant.
@@ -120,24 +125,25 @@ function useAsync<Result = any>( | |||
// 确保不会返回被取消的结果 | |||
const runCount = count.current; | |||
set(s => ({ ...s, loading: true })); | |||
params.current = args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be in front of set(s => ({ ...s, loading: true }));
run: promiseReturn, | ||
timer: { | ||
stop: noop, | ||
resume: promiseReturn, | ||
pause: noop, | ||
}, | ||
}); | ||
const { autoCancel = true } = _options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoCancel
is not a good name~~
but i don't hav any idea~ hhh
docs will be rewritten in the docs branch |
resolve #65, resolve #69