Fix for sortable example
MortalFlesh opened this issue · 1 comments
MortalFlesh commented
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 :)
skoal2007 commented
Thank you. Save me a lot of time.