Last active
January 27, 2018 22:08
-
-
Save goldensunliu/fffaea34a19dc5eb7fb06b177bd3c5fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { 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