Last active
November 28, 2018 21:18
-
-
Save mvbattan/f81ac48bea32a0df152852d5507de705 to your computer and use it in GitHub Desktop.
A component using dServices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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