Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the use of context to get store #37

Merged
merged 1 commit into from Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ dist
node_modules
server/log/*.log
server/.env
npm-debug.log
11 changes: 4 additions & 7 deletions src/containers/App.js
Expand Up @@ -8,7 +8,8 @@ const DEFAULT_TITLE = 'React Boilerplate';
class App extends Component {

componentDidMount() {
App.fetchData(this.context.store);
const { dispatch } = this.props;
App.fetchData(dispatch);
}

render() {
Expand All @@ -22,12 +23,8 @@ class App extends Component {
}
}

App.contextTypes = {
store: PropTypes.object.isRequired
};

App.fetchData = function(store) {
return store.dispatch(fetchPostsIfNeeded());
App.fetchData = function(dispatch) {
return dispatch(fetchPostsIfNeeded());
};

function mapStateToProps(state) {
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Expand Up @@ -14,7 +14,7 @@ function fetchComponentData(renderProps, store) {
component = component.WrappedComponent;
}
if (component.fetchData) {
return component.fetchData(store)
return component.fetchData(store.dispatch)
// Make sure promise always successfully resolves
.catch(() => {});
}
Expand Down