Skip to content

Commit 82ae221

Browse files
committed
📦 Be a bit more terse with passthrough methods
1 parent 18b6297 commit 82ae221

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

src/ImmutableListView/ImmutableListView.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,14 @@ class ImmutableListView extends PureComponent {
158158
return this.listViewRef;
159159
}
160160

161-
getMetrics(...args) {
162-
return this.listViewRef && this.listViewRef.getMetrics(...args);
163-
}
161+
getMetrics = (...args) =>
162+
this.listViewRef && this.listViewRef.getMetrics(...args);
164163

165-
scrollTo(...args) {
166-
return this.listViewRef && this.listViewRef.scrollTo(...args);
167-
}
164+
scrollTo = (...args) =>
165+
this.listViewRef && this.listViewRef.scrollTo(...args);
168166

169-
scrollToEnd(...args) {
170-
return this.listViewRef && this.listViewRef.scrollToEnd(...args);
171-
}
167+
scrollToEnd = (...args) =>
168+
this.listViewRef && this.listViewRef.scrollToEnd(...args);
172169

173170
render() {
174171
const { dataSource } = this.state;
@@ -192,7 +189,7 @@ class ImmutableListView extends PureComponent {
192189

193190
return (
194191
<ListView
195-
ref={(listView) => { this.listViewRef = listView; }}
192+
ref={(component) => { this.listViewRef = component; }}
196193
dataSource={dataSource}
197194
{...this.props}
198195
/>

src/ImmutableVirtualizedList/ImmutableVirtualizedList.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,20 @@ class ImmutableVirtualizedList extends PureComponent {
6666
return this.virtualizedListRef;
6767
}
6868

69-
scrollToEnd(...args) {
70-
return this.virtualizedListRef && this.virtualizedListRef.scrollToEnd(...args);
71-
}
69+
scrollToEnd = (...args) =>
70+
this.virtualizedListRef && this.virtualizedListRef.scrollToEnd(...args);
7271

73-
scrollToIndex(...args) {
74-
return this.virtualizedListRef && this.virtualizedListRef.scrollToIndex(...args);
75-
}
72+
scrollToIndex = (...args) =>
73+
this.virtualizedListRef && this.virtualizedListRef.scrollToIndex(...args);
7674

77-
scrollToItem(...args) {
78-
return this.virtualizedListRef && this.virtualizedListRef.scrollToItem(...args);
79-
}
75+
scrollToItem = (...args) =>
76+
this.virtualizedListRef && this.virtualizedListRef.scrollToItem(...args);
8077

81-
scrollToOffset(...args) {
82-
return this.virtualizedListRef && this.virtualizedListRef.scrollToOffset(...args);
83-
}
78+
scrollToOffset = (...args) =>
79+
this.virtualizedListRef && this.virtualizedListRef.scrollToOffset(...args);
8480

85-
recordInteraction(...args) {
86-
return this.virtualizedListRef && this.virtualizedListRef.recordInteraction(...args);
87-
}
81+
recordInteraction = (...args) =>
82+
this.virtualizedListRef && this.virtualizedListRef.recordInteraction(...args);
8883

8984
render() {
9085
const { immutableData, renderEmpty, renderEmptyInList, contentContainerStyle } = this.props;
@@ -107,7 +102,7 @@ class ImmutableVirtualizedList extends PureComponent {
107102

108103
return (
109104
<VirtualizedList
110-
ref={(virtualizedList) => { this.virtualizedListRef = virtualizedList; }}
105+
ref={(component) => { this.virtualizedListRef = component; }}
111106
data={immutableData}
112107
getItem={(items, index) => utils.getValueFromKey(index, items)}
113108
getItemCount={(items) => (items.size || 0)}

0 commit comments

Comments
 (0)