Skip to content

Commit 27b086d

Browse files
author
Claudéric Demers
authored
Merge pull request clauderic#215 from jschlieber/feature/document-consumed-props
Add doc for unfortunate prop consumption
2 parents c9f767d + dfbb358 commit 27b086d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,29 @@ Upon sorting, `react-sortable-hoc` creates a clone of the element you are sortin
144144
### Click events being swallowed
145145
By default, `react-sortable-hoc` is triggered immediately on `mousedown`. If you'd like to prevent this behaviour, there are a number of strategies readily available. You can use the `distance` prop to set a minimum distance (in pixels) to be dragged before sorting is enabled. You can also use the `pressDelay` prop to add a delay before sorting is enabled. Alternatively, you can also use the [SortableHandle](https://github.com/clauderic/react-sortable-hoc/blob/master/src/SortableHandle/index.js) HOC.
146146

147+
### Wrapper props not passed down to wrapped Component
148+
All props for `SortableContainer` and `SortableElement` listed above are intentionally consumed by the wrapper component and are **not** passed down to the wrapped component. To make them available pass down the desired prop again with a different name. E.g.:
149+
150+
```js
151+
const SortableItem = SortableElement(({value, sortIndex}) =>
152+
<li>{value} - #{sortIndex}</li>
153+
);
154+
155+
const SortableList = SortableContainer(({items}) => {
156+
return (
157+
<ul>
158+
{items.map((value, index) => (
159+
<SortableItem
160+
key={`item-${index}`}
161+
index={index}
162+
sortIndex={index}
163+
value={value}
164+
/>
165+
))}
166+
</ul>
167+
);
168+
});
169+
```
147170

148171
Dependencies
149172
------------

0 commit comments

Comments
 (0)