Skip to content

Instantly share code, notes, and snippets.

@goldensunliu
Last active February 1, 2018 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldensunliu/385447297ba9d475677d8e62a0209dfd to your computer and use it in GitHub Desktop.
Save goldensunliu/385447297ba9d475677d8e62a0209dfd to your computer and use it in GitHub Desktop.
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