Wait for useQuery result
so im checking on load if the current shop is a favourite shop or not, but the favShop is undefined at load then you get the result, since i cant use async await on it, how do i wait for the result so i can use it in the useState
8 Replies
this is how the value of favShop changes on load
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
im using the state for later
i only wanna call the procedure on the first load
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
no im not storing the data in a state, in just checking if the object is empty or not.
i used useEffect
so i need to wait for the status to be success thats how you know the query finished executing
and this is the state
you also can
and every time onSuccess is called, favorite is updated
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ohh cool didnt know i could do this
yeah thats what i thought, didnt like that i used the useEffect
will read it! thank youu