Created
December 18, 2018 10:58
-
-
Save productioncoder/f7e843fd98b0ee1c9cdfd4941a8b4f8a to your computer and use it in GitHub Desktop.
Youtube in React: wiring Watch component up so it can dispatch actions
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 {bindActionCreators} from 'redux'; | |
import * as watchActions from '../../store/actions/watch'; | |
import {withRouter} from 'react-router-dom'; | |
import {connect} from 'react-redux'; | |
import {getYoutubeLibraryLoaded} from '../../store/reducers/api'; | |
function mapStateToProps(state) { | |
return { | |
youtubeLibraryLoaded: getYoutubeLibraryLoaded(state), | |
}; | |
} | |
function mapDispatchToProps(dispatch) { | |
const fetchWatchDetails = watchActions.details.request; | |
return bindActionCreators({fetchWatchDetails}, dispatch); | |
} | |
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Watch)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment