Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,10 @@ describe('Swipeable Specific', () => {
expect(wrapper.instance().testRef).toBe(swipeableDiv)
wrapper.unmount()
})

it('passes down props', () => {
const wrapper = mount(<Swipeable data-testid="custom-prop" />)
expect(wrapper.find('div').prop('data-testid')).toBe('custom-prop')
wrapper.unmount()
})
})
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,18 @@ export class Swipeable extends React.PureComponent {
}

render() {
const { className, style, nodeName = 'div', innerRef, children, trackMouse } = this.props
const {
className,
style,
nodeName = 'div',
innerRef,
children,
trackMouse,
...rest
} = this.props
const [handlers, attachTouch] = getHandlers(this._set, { trackMouse })
this.transientState = updateTransientState(this.transientState, this.props, attachTouch)
const ref = innerRef ? el => (innerRef(el), handlers.ref(el)) : handlers.ref
return React.createElement(nodeName, { ...handlers, className, style, ref }, children)
return React.createElement(nodeName, { ...rest, ...handlers, className, style, ref }, children)
}
}