Skip to content

Commit 37bcaea

Browse files
author
Marek Rozmus
committed
Change refs from inline methods to class methods
1 parent ca3aa15 commit 37bcaea

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/SwipeableListItem.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,26 +188,28 @@ class SwipeableListItem extends PureComponent {
188188
}
189189
};
190190

191+
bindBackgroundLeft = ref => (this.backgroundLeft = ref);
192+
bindBackgroundRight = ref => (this.backgroundRight = ref);
193+
bindListElement = ref => (this.listElement = ref);
194+
bindWrapper = ref => (this.wrapper = ref);
195+
191196
render() {
192197
const { children, swipeLeft, swipeRight } = this.props;
193198

194199
return (
195-
<div className="swipeable-list-item" ref={div => (this.wrapper = div)}>
200+
<div className="swipeable-list-item" ref={this.bindWrapper}>
196201
{swipeLeft && (
197-
<div ref={div => (this.backgroundLeft = div)} className="background">
202+
<div ref={this.bindBackgroundLeft} className="background">
198203
{swipeLeft.background}
199204
</div>
200205
)}
201206
{swipeRight && (
202-
<div
203-
ref={div => (this.backgroundRight = div)}
204-
className="background right"
205-
>
207+
<div ref={this.bindBackgroundRight} className="background right">
206208
{swipeRight.background}
207209
</div>
208210
)}
209211
<div
210-
ref={div => (this.listElement = div)}
212+
ref={this.bindListElement}
211213
onMouseDown={this.onDragStartMouse}
212214
onTouchStart={this.onDragStartTouch}
213215
className="content"

0 commit comments

Comments
 (0)