A
A
alexandrzbs2019-10-10 18:19:11
React
alexandrzbs, 2019-10-10 18:19:11

Does state participate in React to manage data coming through GraphQL (Apollo)?

Hello, I'm a beginner front-end developer. Now I'm just getting acquainted with apollo-graphql. In the course of the project implementation, I noticed that the data from gql queries / mutations / subscriptions does not need state in react. This is just my observation, based on the first experience, and I would like you to share best practices.
The bottom line:
When I use query/mutation/subscription I use hooks. Hooks only work in functional components, so using state is not an option here. Further, this data is either immediately rendered by JSX or goes to someone in props and is rendered there. It turns out that the data from the server is not fixed anywhere.but they fly right down / up and are rendered where I need. At the same time, everything works, everything is class, realtime. But this worries me, because I'm used to the fact that the state is the basis, it's control.
(Even if I didn't use hooks and could store state in components or raise it up, BUT is it necessary? All the examples on the apollo site hint that it isn't)
I read about how graphql caused Redux to stop be so necessary and useful, since graphql is about local state history. And, they say, on graphlql projects everything is cleaner and clearer than on redux. Although these are completely different tools, it so happened that one leads to the inconvenience of using the other.
Okay, but answer my question: how should I use local state with graphql?
Thank you all in advance for your replies. I ask you to treat with understanding, to my amateurish question :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question