{"action":"created","issue":{"url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet/issues/49","repository_url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet","labels_url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet/issues/49/comments","events_url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet/issues/49/events","html_url":"https://github.com/sw-yx/react-typescript-cheatsheet/issues/49","id":372345467,"node_id":"MDU6SXNzdWUzNzIzNDU0Njc=","number":49,"title":"Context - Provider & Consumer should be a pair","user":{"login":"dance2die","id":8465237,"node_id":"MDQ6VXNlcjg0NjUyMzc=","avatar_url":"https://avatars1.githubusercontent.com/u/8465237?v=4","gravatar_id":"","url":"https://api.github.com/users/dance2die","html_url":"https://github.com/dance2die","followers_url":"https://api.github.com/users/dance2die/followers","following_url":"https://api.github.com/users/dance2die/following{/other_user}","gists_url":"https://api.github.com/users/dance2die/gists{/gist_id}","starred_url":"https://api.github.com/users/dance2die/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dance2die/subscriptions","organizations_url":"https://api.github.com/users/dance2die/orgs","repos_url":"https://api.github.com/users/dance2die/repos","events_url":"https://api.github.com/users/dance2die/events{/privacy}","received_events_url":"https://api.github.com/users/dance2die/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-21T18:56:53Z","updated_at":"2018-10-22T18:48:01Z","closed_at":null,"author_association":"NONE","body":"[Context](https://github.com/sw-yx/react-typescript-cheatsheet#context) shows how to create a provider but doesn't provide a way to use the `Consumer`.\r\n\r\nWhat do you think about providing a code snippet for the consumer as well?\r\n\r\nI can do a PR for the code snippet that shows how to consume using `Consumer`\r\n\r\n[![Edit jlqo76kxov](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/jlqo76kxov)\r\n\r\n```javascript\r\nimport * as React from \"react\";\r\nimport { render } from \"react-dom\";\r\nimport { Provider, Consumer, ProviderStore } from \"./components/Provider.tsx\";\r\n\r\nconst App = () => (\r\n  <div style={styles}>\r\n    <Provider>\r\n      <Consumer>\r\n        {(store: ProviderStore) => (\r\n          <div>\r\n            <span>Theme Color: </span>\r\n            <p style={{ color: store.state.themeColor }}>\r\n              {store.state.themeColor}\r\n            </p>\r\n          </div>\r\n        )}\r\n      </Consumer>\r\n    </Provider>\r\n  </div>\r\n);\r\n\r\nrender(<App />, document.getElementById(\"root\"));\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet/issues/comments/431933634","html_url":"https://github.com/sw-yx/react-typescript-cheatsheet/issues/49#issuecomment-431933634","issue_url":"https://api.github.com/repos/sw-yx/react-typescript-cheatsheet/issues/49","id":431933634,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTkzMzYzNA==","user":{"login":"sw-yx","id":6764957,"node_id":"MDQ6VXNlcjY3NjQ5NTc=","avatar_url":"https://avatars1.githubusercontent.com/u/6764957?v=4","gravatar_id":"","url":"https://api.github.com/users/sw-yx","html_url":"https://github.com/sw-yx","followers_url":"https://api.github.com/users/sw-yx/followers","following_url":"https://api.github.com/users/sw-yx/following{/other_user}","gists_url":"https://api.github.com/users/sw-yx/gists{/gist_id}","starred_url":"https://api.github.com/users/sw-yx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sw-yx/subscriptions","organizations_url":"https://api.github.com/users/sw-yx/orgs","repos_url":"https://api.github.com/users/sw-yx/repos","events_url":"https://api.github.com/users/sw-yx/events{/privacy}","received_events_url":"https://api.github.com/users/sw-yx/received_events","type":"User","site_admin":false},"created_at":"2018-10-22T18:48:01Z","updated_at":"2018-10-22T18:48:01Z","author_association":"OWNER","body":"ok but the new contexttype api is going to be released soon. lets make sure to recommend that first before the render props"}}
{"actor":{"display_login":"sw-yx"}}