Skip to content

Instantly share code, notes, and snippets.

@goldensunliu
Last active January 27, 2018 22:08
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/fffaea34a19dc5eb7fb06b177bd3c5fb to your computer and use it in GitHub Desktop.
Save goldensunliu/fffaea34a19dc5eb7fb06b177bd3c5fb to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchAudioFeaturesById } from '../actions';
// stateless template for the display
import AudioFeatures from '../AudioFeatures'
const mapStateToProps = ({audioFeaturesById}, {trackId}) => ({
audioFeatures: audioFeaturesById[trackId]
});
const mapDispatchToProps = (dispatch) => ({
fetchFeatures: (trackId) => dispatch(fetchAudioFeaturesById(trackId))
});
class ConnectedAudioFeatures extends React.Component {
...
componentWillMount() {
const { fetchFeatures, trackId } = this.props;
fetchFeatures(trackId);
}
render() {
const { audioFeature } = this.props
return (<AudioFeatures audioFeature={audioFeature}/>)
}
...
};
export default connect(mapDispatchToProps, dispatchToProps)(ConnectedAudioFeatures);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment