{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/13969","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/13969/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/13969/comments","events_url":"https://api.github.com/repos/facebook/react/issues/13969/events","html_url":"https://github.com/facebook/react/issues/13969","id":374032228,"node_id":"MDU6SXNzdWUzNzQwMzIyMjg=","number":13969,"title":"16.6 Context API not working in class component","user":{"login":"dericgw","id":34040106,"node_id":"MDQ6VXNlcjM0MDQwMTA2","avatar_url":"https://avatars2.githubusercontent.com/u/34040106?v=4","gravatar_id":"","url":"https://api.github.com/users/dericgw","html_url":"https://github.com/dericgw","followers_url":"https://api.github.com/users/dericgw/followers","following_url":"https://api.github.com/users/dericgw/following{/other_user}","gists_url":"https://api.github.com/users/dericgw/gists{/gist_id}","starred_url":"https://api.github.com/users/dericgw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dericgw/subscriptions","organizations_url":"https://api.github.com/users/dericgw/orgs","repos_url":"https://api.github.com/users/dericgw/repos","events_url":"https://api.github.com/users/dericgw/events{/privacy}","received_events_url":"https://api.github.com/users/dericgw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-25T16:31:17Z","updated_at":"2018-10-25T19:07:58Z","closed_at":null,"author_association":"NONE","body":"**Do you want to request a *feature* or report a *bug*?**\r\nQuite possibly a bug (or maybe confusion about the current API)\r\n\r\nI am using the new Context API as well as the new `static contextType` in React 16.6. I am passing context down a couple components deep but when I attempt to access the context within the component, the object is empty (only the default value passed into `createContext` is being displayed). This is happening in a current feature I am working on at my job, so I cannot display that code, but I did create a Codesandbox with the gist of the problem.\r\n\r\nHere is a demonstration of the behavior: https://codesandbox.io/s/r4myz959ro\r\n\r\nI would expect to be able to access the current values of the context. This way, if those values change, I would always have the most recent values. Now, maybe this is expected behavior, however, it would be confusing if it is.\r\n\r\nReact 16.6\r\nReactDOM 16.6\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/433170134","html_url":"https://github.com/facebook/react/issues/13969#issuecomment-433170134","issue_url":"https://api.github.com/repos/facebook/react/issues/13969","id":433170134,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzE3MDEzNA==","user":{"login":"javascrewpt","id":11208176,"node_id":"MDQ6VXNlcjExMjA4MTc2","avatar_url":"https://avatars3.githubusercontent.com/u/11208176?v=4","gravatar_id":"","url":"https://api.github.com/users/javascrewpt","html_url":"https://github.com/javascrewpt","followers_url":"https://api.github.com/users/javascrewpt/followers","following_url":"https://api.github.com/users/javascrewpt/following{/other_user}","gists_url":"https://api.github.com/users/javascrewpt/gists{/gist_id}","starred_url":"https://api.github.com/users/javascrewpt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javascrewpt/subscriptions","organizations_url":"https://api.github.com/users/javascrewpt/orgs","repos_url":"https://api.github.com/users/javascrewpt/repos","events_url":"https://api.github.com/users/javascrewpt/events{/privacy}","received_events_url":"https://api.github.com/users/javascrewpt/received_events","type":"User","site_admin":false},"created_at":"2018-10-25T19:07:58Z","updated_at":"2018-10-25T19:07:58Z","author_association":"NONE","body":"Thanks, didn't know that. What I did figure was when you export context from index.js and import it in that component, it's an empty object. Then I tried to export a regular object with a few properties and import it the same and it was an empty object again. So I added an additional file and export just the context with the default values and now it seems to work. https://codesandbox.io/s/xjj2nq5r34"}}
{"actor":{"display_login":"javascrewpt"}}