{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/react-redux/issues/57","repository_url":"https://api.github.com/repos/rackt/react-redux","labels_url":"https://api.github.com/repos/rackt/react-redux/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/rackt/react-redux/issues/57/comments","events_url":"https://api.github.com/repos/rackt/react-redux/issues/57/events","html_url":"https://github.com/rackt/react-redux/issues/57","id":101122670,"number":57,"title":"Could not find \"store\" in either the context or props","user":{"login":"anthonator","id":420061,"avatar_url":"https://avatars.githubusercontent.com/u/420061?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonator","html_url":"https://github.com/anthonator","followers_url":"https://api.github.com/users/anthonator/followers","following_url":"https://api.github.com/users/anthonator/following{/other_user}","gists_url":"https://api.github.com/users/anthonator/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonator/subscriptions","organizations_url":"https://api.github.com/users/anthonator/orgs","repos_url":"https://api.github.com/users/anthonator/repos","events_url":"https://api.github.com/users/anthonator/events{/privacy}","received_events_url":"https://api.github.com/users/anthonator/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-14T23:43:17Z","updated_at":"2016-02-05T00:27:43Z","closed_at":"2015-08-15T00:39:11Z","body":"I get a `Could not find \"store\" in either the context or props` error whenever I try to `connect` a component to Redux.\r\n\r\nWhen I'm in the debug console I can see that `state` is defined on `this` and `context` but it has a value of `undefined`. Also, when I inspect `createStore` I get an object back with `dispatch`, `getState`, etc.\r\n\r\n```js\r\nimport { Provider } from 'react-redux';\r\nimport React from 'react';\r\nimport reducers from '../config/reducers';\r\nimport { createStore } from 'redux';\r\nimport routes from '../config/routes';\r\n\r\nReact.render(\r\n  <Provider store={ createStore(reducers) }>\r\n    { () => routes }\r\n  </Provider>\r\n, document.body);\r\n\r\n```\r\n\r\n**Component**\r\n```js\r\nimport React from 'react';\r\n\r\n// components\r\nimport Footer from './_footer';\r\nimport Header from './_header';\r\n\r\n// redux\r\nimport { connect } from 'react-redux';\r\n\r\nimport ClientSessionActionCreators from '../../actions/client-session-action-creators';\r\n\r\nclass ApplicationLayout extends React.Component {\r\n  render() {\r\n    return (\r\n      <div>\r\n        <Header />\r\n        { this.props.children }\r\n        <Footer />\r\n      </div>\r\n    );\r\n  }\r\n}\r\n\r\nexport default connect(state => state)(ApplicationLayout);\r\n```"},"comment":{"url":"https://api.github.com/repos/rackt/react-redux/issues/comments/180121722","html_url":"https://github.com/rackt/react-redux/issues/57#issuecomment-180121722","issue_url":"https://api.github.com/repos/rackt/react-redux/issues/57","id":180121722,"user":{"login":"DelvarWorld","id":79215,"avatar_url":"https://avatars.githubusercontent.com/u/79215?v=3","gravatar_id":"","url":"https://api.github.com/users/DelvarWorld","html_url":"https://github.com/DelvarWorld","followers_url":"https://api.github.com/users/DelvarWorld/followers","following_url":"https://api.github.com/users/DelvarWorld/following{/other_user}","gists_url":"https://api.github.com/users/DelvarWorld/gists{/gist_id}","starred_url":"https://api.github.com/users/DelvarWorld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DelvarWorld/subscriptions","organizations_url":"https://api.github.com/users/DelvarWorld/orgs","repos_url":"https://api.github.com/users/DelvarWorld/repos","events_url":"https://api.github.com/users/DelvarWorld/events{/privacy}","received_events_url":"https://api.github.com/users/DelvarWorld/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T00:27:43Z","updated_at":"2016-02-05T00:27:43Z","body":"I'm having a very strange issue related to this and I'm not sure what's going on.\r\n\r\nI'm using [react-redux-universal-hot-example](https://github.com/erikras/react-redux-universal-hot-example) as my base.\r\n\r\nThe top level component looks like this:\r\n\r\n    const component = (\r\n        <ReduxRouter routes={getRoutes(store)} />\r\n    );\r\n\r\n    ReactDOM.render(\r\n        <Provider store={store} key=\"provider\">\r\n            {component}\r\n        </Provider>,\r\n        dest\r\n    );\r\n\r\nThe route handler uses `@connectData` and `@connect`:\r\n\r\n    @connectData( fetchData )\r\n    @connect(\r\n        state => ({ ... })\r\n    )\r\n    export default class HighLevelComponent extends Component {\r\n        render() {\r\n            return <SubComponent />;\r\n        }\r\n    }\r\n\r\n`<SubComponent />` only has `@connect`:\r\n\r\n    @connect( state => ({ ... }) )\r\n    export default class SubComponent extends Component {\r\n        render() {\r\n            return <ChildWithConnect />\r\n        }\r\n    }\r\n\r\n**This errors.**\r\n> Warning: Failed Context Types: Required context `store` was not specified in `Connect(ChildWithConnect)`. Check the render method of `SubComponent`.\r\n> Uncaught Invariant Violation: Could not find \"store\" in either the context or props of \r\n\"Connect(ChildWithConnect)\". Either wrap the root component in a <Provider>, or explicitly pass \"store\" as a prop to \"Connect(ChildWithConnect)\"\r\n\r\nThis happens even if I have `contextTypes` defined:\r\n\r\n    ChildWithConnect.contextTypes = {\r\n        store: PropTypes.object.isRequired\r\n    };\r\n\r\nIf I make `<ChildWithConnect />` a direct child of `<HighLevelComponent />`, then there is no error.\r\n\r\nYou can see in the call stack for the error/warning above, `context` is an empty object and `maskedContext` has `undefined` for the store key:\r\n\r\n ![screen shot 2016-02-04 at 4 25 45 pm](https://cloud.githubusercontent.com/assets/79215/12834418/fbc3b77a-cb5b-11e5-86ce-c3dece278bd2.png)\r\n\r\nSince it's defined as a `contextType`, shouldn't my sub component get the `store` passed to it automatically? Been pulling my hair out over this for a while, and I'm not sure if this is desired behavior, a bug, or I'm doing something incorrectly. "}}