Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created December 18, 2018 10:58
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 productioncoder/f7e843fd98b0ee1c9cdfd4941a8b4f8a to your computer and use it in GitHub Desktop.
Save productioncoder/f7e843fd98b0ee1c9cdfd4941a8b4f8a to your computer and use it in GitHub Desktop.
Youtube in React: wiring Watch component up so it can dispatch actions
/* ... */
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