So Iโm having that issue with React where all the cloud function calls I define in my page are being called when the page is mounted. This is obviously a problem since I only want those functions to be called when I call them
This is maybe due to the new react strict mode that automatically remount the components, not sure about that, but i donโt think so, I guess this just makes that the functions are called twice ><
Here is how I declare my functions :
const {
fetch: fixDbFetch,
data: fixDbData,
error: fixDbError,
} = useMoralisCloudFunction('fixDb', { autoFetch: false });
the react moralis doc say this about autofetch :
If you want to disable the automatic fetching, you can also manually fetch. You need to provide autoFetch: false
as option in the 4th argument. In that case it will ignore the dependencies and will only fetch if you manually call fetch()
But i guess this is only to prevent fetch on dependency update. not on mount apparently.
Is there any way to declare that within a function and not inside the component ?
Thanks