Skip to content

Instantly share code, notes, and snippets.

@mvbattan
Last active November 28, 2018 21:18
Show Gist options
  • Save mvbattan/f81ac48bea32a0df152852d5507de705 to your computer and use it in GitHub Desktop.
Save mvbattan/f81ac48bea32a0df152852d5507de705 to your computer and use it in GitHub Desktop.
A component using dServices
import React, { Component } from 'react';
import { connect } from 'react-redux';
import SoccerService from '../Services/SoccerService.js';
class MatchList extends Component {
componentDidMount() {
this.props.dispatch(SoccerService.getMatches());
}
render() {
// Do JSX Stuff
}
}
// Since there is no initial state yet
MatchList.defaultProps = {
matchList: []
};
const mapStateToProps = state => ({
// The result of the API Call will be stored here due to
// mystic invisible handling
matchList: state.soccer.getMatches
});
export default connect(mapStateToProps)(MatchList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment