-
Notifications
You must be signed in to change notification settings - Fork 90
Closed
Description
deferFn should resolve the value of it's underlying promise, however it actually always resolves false:
const { data, run, setData } = useAsync({
initialValue: defaultContext,
deferFn: customerLogin,
});
if (doLogin) {
run(customerId).then(console.log);
}Logs false.
I would expect to get the object resolved by the Promise that customerLogin returns.
I want to be able to extract the value from the promise deferFn resolves, then call setData with the resolved response so the component re-renders with the new data e.g.
const { data, run, setData } = useAsync({
initialValue: defaultContext,
deferFn: customerLogin,
});
if (doLogin) {
run(customerId).then(customer => setData(customer));
}I need to use deferFn because I only want to run the promise conditionally, promiseFn (which does return the resolved value as expected) executes automatically so wouldn't work here, but I also want to get the data resolved from the deferred promise as well.
Metadata
Metadata
Assignees
Labels
No labels