Skip to content

Instantly share code, notes, and snippets.

@tmikeschu
Last active December 9, 2017 17:21
Show Gist options
  • Save tmikeschu/6d0f4f5de503402d15b3e276c7f8bbfd to your computer and use it in GitHub Desktop.
Save tmikeschu/6d0f4f5de503402d15b3e276c7f8bbfd to your computer and use it in GitHub Desktop.
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));
import React from 'react';
const Sidebar = (props) => (
{props.photosList}
);
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