{"action":"closed","issue":{"url":"https://api.github.com/repos/apollographql/apollo-feature-requests/issues/64","repository_url":"https://api.github.com/repos/apollographql/apollo-feature-requests","labels_url":"https://api.github.com/repos/apollographql/apollo-feature-requests/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/apollo-feature-requests/issues/64/comments","events_url":"https://api.github.com/repos/apollographql/apollo-feature-requests/issues/64/events","html_url":"https://github.com/apollographql/apollo-feature-requests/issues/64","id":374589378,"node_id":"MDU6SXNzdWUzNzQ1ODkzNzg=","number":64,"title":"React `useContext`","user":{"login":"lifeiscontent","id":180963,"node_id":"MDQ6VXNlcjE4MDk2Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/180963?v=4","gravatar_id":"","url":"https://api.github.com/users/lifeiscontent","html_url":"https://github.com/lifeiscontent","followers_url":"https://api.github.com/users/lifeiscontent/followers","following_url":"https://api.github.com/users/lifeiscontent/following{/other_user}","gists_url":"https://api.github.com/users/lifeiscontent/gists{/gist_id}","starred_url":"https://api.github.com/users/lifeiscontent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifeiscontent/subscriptions","organizations_url":"https://api.github.com/users/lifeiscontent/orgs","repos_url":"https://api.github.com/users/lifeiscontent/repos","events_url":"https://api.github.com/users/lifeiscontent/events{/privacy}","received_events_url":"https://api.github.com/users/lifeiscontent/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-27T00:51:33Z","updated_at":"2018-11-21T22:54:59Z","closed_at":"2018-11-21T22:54:59Z","author_association":"NONE","body":"I'd love to see apollo take advantage of `useContext` in the new release of React.\r\n\r\npotentially simplifying some of the work with Query Component, ApolloConsumer, etc.\r\n\r\ne.g. (this is pseudo code)\r\n\r\n``` js\r\nimport React, { useState, useEffect, useContext } from 'react';\r\nimport { ApolloContext, gql } from 'react-apollo';\r\n\r\nfunction useQuery(query) {\r\n  const [data, setData] = useState(null);\r\n  const apollo = useContext(ApolloContext);\r\n\r\n  function handleDataChange(data) {\r\n    setData(data);\r\n  }\r\n\r\n  useEffect(() => {\r\n    return apollo.watchQuery(query).valueChanges.subscribe(handleDataChange);\r\n  });\r\n\r\n  return data;\r\n}\r\n\r\nfunction ListView() {\r\n  const data = useQuery({\r\n    query: gql`\r\n      {\r\n        posts {\r\n          title\r\n        }\r\n      }\r\n    `,\r\n  });\r\n\r\n  return (\r\n    <ol>\r\n      {data.posts.map((item, index) => (\r\n        <li key={index}>{item.title}</li>\r\n      ))}\r\n    </ol>\r\n  );\r\n}\r\n```\r\n\r\nI'd expect `useApollo`, `useQuery`, `useMutation`, etc to be a hook apollo would provide"}}
{"actor":{"display_login":"lifeiscontent"}}