Last active
February 1, 2018 16:34
-
-
Save goldensunliu/385447297ba9d475677d8e62a0209dfd to your computer and use it in GitHub Desktop.
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 withRedux from '../nextWithReduxWrapper'; | |
import { FETCH_PLAY_HISTORY } from '../actions'; | |
import PlayHistory from '../components/PlayHistory'; | |
const mapStateToProps = ({ history, artistsById, audioFeaturesById }) => { | |
return { history, artistsById, audioFeaturesById }; | |
}; | |
const mapDispatchToProps = (dispatch) => { | |
return { | |
fetchHistory: () => dispatch(FETCH_PLAY_HISTORY) | |
}; | |
}; | |
class PlayHistoryPage extends React.Component { | |
... | |
async getInitialProps() { | |
const { fetchHistory } = this.props; | |
fetchHistory(); | |
} | |
... | |
render() { | |
const { history, artistsById, audioFeaturesById } = this.props | |
return (<PlayHistory history={history} artistsById={artistsById} audioFeaturesById={audioFeaturesById}/>) | |
} | |
}; | |
export default withRedux(connect(mapDispatchToProps, dispatchToProps)(PlayHistoryPage)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment