#How to fetch useMutation like useQuery on mount (without having to call mutate in useEffect)?
3 messages · Page 1 of 1 (latest)
React only does that in when in development so it won't cause an issue in production.
But then again I wouldn't recommend calling either mutation or query in a useEffect if you can help it.
I tried this:
const hasMounted = useRef(false); useEffect(() => { if (!hasMounted.current) { mutate(selectedPlayers); hasMounted.current = true; } }, []);
The mutation happens (the new match is visible in the BE), but it stays in a state of loading all the time for some reason.
Any idea why?