How to setState() in React/Apollo with graphQL

前端 未结 3 1758
醉话见心
醉话见心 2021-02-04 20:14

I am trying to setState() to a query result I have from graphQL, but I am having difficulty finding out how to do this because it will always be loading, or it\'s only used from

3条回答
  •  误落风尘
    2021-02-04 20:41

    What is the reason behind setting it to state? Keep in mind, Apollo Client uses an internal redux store to manage queries. If you're trying to trigger a re render based on when something changes in the query, you should be using refetchQueries(). If you absolutely need to store it in local state, I would assume you could probably compare nextProps in componentWillReceiveProps to detect when loading (the value that comes back when you execute a query from apollo client) has changed, then update your state.

提交回复
热议问题