{"action":"opened","issue":{"url":"https://api.github.com/repos/rackt/redux/issues/916","labels_url":"https://api.github.com/repos/rackt/redux/issues/916/labels{/name}","comments_url":"https://api.github.com/repos/rackt/redux/issues/916/comments","events_url":"https://api.github.com/repos/rackt/redux/issues/916/events","html_url":"https://github.com/rackt/redux/issues/916","id":112060014,"number":916,"title":"Calling store.dispatch() from a React component file?","user":{"login":"alexklibisz","id":8015228,"avatar_url":"https://avatars.githubusercontent.com/u/8015228?v=3","gravatar_id":"","url":"https://api.github.com/users/alexklibisz","html_url":"https://github.com/alexklibisz","followers_url":"https://api.github.com/users/alexklibisz/followers","following_url":"https://api.github.com/users/alexklibisz/following{/other_user}","gists_url":"https://api.github.com/users/alexklibisz/gists{/gist_id}","starred_url":"https://api.github.com/users/alexklibisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexklibisz/subscriptions","organizations_url":"https://api.github.com/users/alexklibisz/orgs","repos_url":"https://api.github.com/users/alexklibisz/repos","events_url":"https://api.github.com/users/alexklibisz/events{/privacy}","received_events_url":"https://api.github.com/users/alexklibisz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-19T02:24:59Z","updated_at":"2015-10-19T02:24:59Z","closed_at":null,"body":"I apologize if this is something that has already been cleared up, but a keyword search in the issues didn't turn up anything that helped.\r\n\r\nIf I want to call ```store.dispatch(someAction)``` from a component file, what is the correct way to access the ```store``` instance?\r\n\r\nRight now I have the following, which works, but I'm not sure that it's the right approach:\r\n\r\nindex.jsx:\r\n```\r\n...\r\nconst store = applyMiddleware(\r\n  loggingMiddleware, // log every action\r\n  thunk // making API requests from actions\r\n)(createStore)(reducer);\r\n\r\nexport {\r\n  store\r\n};\r\n...\r\n```\r\n\r\nControls.jsx\r\n```\r\nimport {store} from './index.jsx';\r\nimport * as actions from './actions';\r\n...\r\nlet clickHandler = function(node, data) {\r\n  store.dispatch(actions.nodeClicked(data))\r\n}\r\nexport const Controls = React.createClass({\r\n  render: function() {\r\n    // React component gets rendered, and it passes the clickHandler to a \r\n    // function that attaches it to a D3 visualization\r\n  }\r\n});\r\n```\r\n\r\nIs there anything wrong with exporting/importing the store like this? I think I could just create the click handlers as part of the React component and call ```this.context.store```, but in reality there are about a dozen different event handlers that get passed to the D3 visualization, so that's not really practical in this situation."}}