Skip to content

Commit 4c19656

Browse files
committed
fix(wx-react-native): 修复FlatList onReachEnd多次调用的bug
1 parent 7ca826f commit 4c19656

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,16 @@ Component({
195195
return
196196
}
197197

198-
if (this.compInst.props.data === this.endReachedInvokeData) {
199-
return
200-
}
198+
const query = wx.createSelectorQuery().in(this)
199+
query.select('#container').boundingClientRect((res) => {
200+
const height = res.height
201+
if (this.lastHeight === height) return
202+
201203

202-
this.endReachedInvokeData = this.compInst.props.data
203-
const method = getPropsMethod(this, 'onEndReached')
204-
method && method()
204+
this.lastHeight = height
205+
const method = getPropsMethod(this, 'onEndReached')
206+
method && method()
207+
}).exec()
205208
}
206209
},
207210
data: {

packages/wx-react-native/miniprogram_dist/component/WXFlatList/index.wxml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
lower-threshold="{{100}}"
3232
scroll-into-view="{{index_id}}"
3333
>
34-
<view style="{{contentContainerStyle}}min-height: calc(100% + {{onRefreshPassed ? 80 : 0}}px)">
34+
<view id="container" style="{{contentContainerStyle}}min-height: calc(100% + {{onRefreshPassed ? 80 : 0}}px)">
3535
<view
3636
wx:if="{{onRefreshPassed}}"
3737
style="height:80px;align-items:center;justify-content:center;"

0 commit comments

Comments
 (0)