How to set variables after async function call returns?
const fetch = async () => {
await function_here { ... }
};
const {
data: mintData,
write: mint,
isLoading: isMintLoading,
isSuccess: isMintStarted,
} = useContractWrite(contractConfig, 'mint', {
args: [ARGS_FROM_ASYNC_FETCH_CALL_HERE],
});
I tried doing
const {
data: mintData,
write: mint,
isLoading: isMintLoading,
isSuccess: isMintStarted,
} = fetch().then((result) => useContractWrite(contractConfig, 'mint', {
args: [result],
}));
However, that didn't work due to "Hooks can only be called inside of the body of a function component." How am I supposed to populate ARGS_FROM_ASYNC_FETCH_CALL_HERE from the async function if I can't chain promises?