#How to fetch useMutation like useQuery on mount (without having to call mutate in useEffect)?

3 messages · Page 1 of 1 (latest)

rugged canyon
#

Calling mutate in useEffect makes the call to the BE twice (because of react strict mode) and does two mutations, which is a no go.

An option would be to use useQuery intead of useMutation for this mutation, but that's probably a wrong approach.

pine cipher
#

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.

rugged canyon