I just recently started to learn GraphQL and React-Apollo and I'm wondering what's the recommended approach of using useQuery
and useMutation
hooks if I need them inside the same component.
Since both hooks return {data, loading, error}
object the names are conflicting. Should I just assign unique names to the properties while destructuring or is it better to move the logic to separate container components?
Apollo hooks useQuery and useMutation under the same component [closed]
Asked Answered
© 2022 - 2024 — McMap. All rights reserved.
then
/catch
) 3. you don't have to destructure,xyzMutation.error
is fine. I think the really nice thing about hooks is that it is easy and convinient to use multiple at once (thin aboutuseState
). – Reformationconst { data: userData } = useQuery()
– Gigigigli