我有一個scrollview組件,當我把它包裹在react-native-pull-to-refresh周圍時,無論它被參考到哪里,都沒有觸發。 下面是同樣的代碼,
<PTRView onRefresh={fetchMoreMessages}>
<ScrollView。
ref={scrollviewref}。
onScroll={onScroll}。
scrollEventThrottle={16}
// onContentSizeChange={()/span> =>
// scrollviewref.current.scrollToEnd({animated: true})
// }
>
<View style={{padding: 10, paddingBottom: 70}}>
{message&& displayMessageList(message)}。
{selectsymptomcontent &&
selectsymptomcontent.output &&
renderSelectSymptomCard()}
{nextpageaction !== 'dummytext' && renderNextPageSymptom()}。
{posting == true &&
'dummytext' != selectsymptomcontent &&
nextpageaction !== 'dummytext' && (
<Text style={{fontSize: 15}>>
檢查您的回復,請稍等
<AnimatedEllipsis />
</Text>
)}
</View> )}</View> )
{loadingmessages === true && (
<View View
style={{}。
justifyContent: 'center' 。
alignItems: 'center',
position: 'absolute',
backgroundColor: '#F5FCFF88',
底部: 0,
left: 0,
top: 0,
右邊: 0,
}}>
< ActivityIndicator size="small" color="#000" />
</查看>
)}
</ScrollView> )} </ScrollView> )
</PTRView>
{scrollToBottom==true&& (
<TouchableOpacity style={{位置。 'absolute',bottom:'10%',right:'5%'}}. onPress={()/span>=>{
console.log('HHHHHH')
scrollviewref?.current.scrollToEnd({animated: true})
}}>。
< AntDesignIcon name="downcircle" size={30} color="rgba(0, 0,0,0. 3)"/>
</TouchableOpacity>/span>
)}
在這里,在TouchableOpacity的回呼中,控制臺被列印出來了,但是第二行卻沒有作業。
另外,最初我想讓滾動視圖指向底部。 因此,我也有以下的代碼,但即使這樣也沒有觸發,除了控制臺的列印正常。
if(scrollviewref & & scrollviewref.current & & scrollviewref. current! =undefined && scrollviewref.current! ==null && scrollviewref.current.scrollToEnd && scrollviewref. current.scrollToEnd! ==null && moreClicked==false){
console.log('pppppppp')
setTimeout(()=>/span>{
if(scrollviewref &&scrollviewref.current && scrollviewref.current! ==undefined && scrollviewref.current!==null && scrollviewref. current.scrollToEnd && scrollviewref.current. scrollToEnd!==null && moreClicked==false){
scrollviewref.current.scrollToEnd({animated: true})
}
},1000)
console.log('hhhhhh')
}
這是一個非常奇怪的情況,我不明白如何解決,請幫助我,任何線索都會很好。
uj5u.com熱心網友回復:
我建議使用RefreshControl,而不是像react-native-pull-to-refresh的第三方組件
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/307000.html
標籤:
