Last active
December 9, 2017 17:21
-
-
Save tmikeschu/6d0f4f5de503402d15b3e276c7f8bbfd 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 { connect } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
import * as actions from '../../../redux/actions'; | |
import withPhotos from './withPhotos'; | |
import Sidebar from './sidebar'; | |
const mapStateToProps = state => state; | |
const mapDispatchToProps = dispatch => ({ | |
actions: bindActionCreators(actions, dispatch), | |
}); | |
const connection = connect(mapStateToProps, mapDispatchToProps); | |
export default connection(withPhotos(Sidebar)); |
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 from 'react'; | |
const withPhotos = (Component) => (props) => { | |
const photos = props.photos.map(photo => ( | |
<div className="photo" key={photo.name}> | |
<img src={photo.url} alt={photo.name} /> | |
</div> | |
); | |
return <Component {...props} photosList={photos} />; | |
}; | |
export default withPhotos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment