neptunian / react-photo-gallery

React Photo Gallery

Home Page:http://neptunian.github.io/react-photo-gallery/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix for sortable example

MortalFlesh opened this issue · comments

Hello,
first of all, thanks for this library!

I'm working on sortable gallery, and I need an index inside a Photo component.

In example code for this here . It works fine, but with react-sortable-hoc:^1.10 they

don't spread the keysToOmit parameter in omit util

So the index itself is omitted as well.

I've found this "work-around" or fix for this.

const SortablePhoto = index =>
  SortableElement(item => <Photo {...item} index={index} />);
const SortableGallery = SortableContainer(({ items }) => (
  <Gallery
    photos={items}
    renderImage={props => {
      const IndexedSortablePhoto = SortablePhoto(props.index);

      return <IndexedSortablePhoto {...props} />;
    }}
  />
));

There might be a better way to do it, but for those who struggle with this as me, it could be helpful.

So please, consider to update your example as well.

Thank you :)

Thank you. Save me a lot of time.