Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- fcm push
- 모달
- Icon
- 2023년 정처기 필기
- 가격자릿수
- 순열
- touchableopacity
- 리액트
- react-native
- 리액트네이티브
- algorithm
- 모달에서뒤로가기
- API
- asyncstorage
- Flatlist
- fcm 푸시
- 리액트 네이티브
- 알고리즘
- 자동로그인
- ReactNative
- makePermutation
- React
- C++98에러
- TextInput
- 재귀함수
- 페이지리렌더링
- vision-camera
- 뒤로가기구현
- modal
- JSON
Archives
- Today
- Total
생각은 길게 코딩은 짧게
[React-Native] FlatList 새로고침 ( Page Refresh ) 본문
728x90
상품등록 후 홈의 등록 된 상품 리스트 화면에서 등록 된 상품들이 갱신이 되기 위해 Refresh 기능이 필요하였다
constructor(props){
this.state={ refreshing : false }
}
- 초기 렌더링 시에는 사용자로부터 refresh 이벤트를 받지 않았음으로 false로 지정
//데이터 가지고오는 함수
_getData = () => {
this.callGetRepairAPI().then((response) => {
this.Contents = response;
this.setState({ goodsContent: response });
});
console.log('refresh success')
this.setState({ refreshing: false })
}
- 새로고침이 되었을 때 데이터를 가져올 함수 구현
//새로고침
_handleRefresh = () => {
this.setState({
refreshing: true,
}, this._getData);
}
- 새로고침이 될 때 refreshing의 값을 true로 setState 해주고 getData 함수를 호출
<FlatList
data={this.state.goodsContent}
renderItem={({ item }) => <GetImages item={item} />}
refreshing={this.state.refreshing}
onRefresh={this._handleRefresh}
/>
- onRefresh 속성으로 전달한 함수는 핸드폰 화면을 아래로 당길 때 실행
'React Native' 카테고리의 다른 글
[React-Native] TextInput 별표(*)로 표시하기 (0) | 2022.11.28 |
---|---|
[React-Native] React-Native 완벽하고 빠르게 환경설정 (0) | 2022.11.21 |
[React-Native] <Text> 글자 수 제한하기 (0) | 2022.11.17 |
[React-Native] 유효성 검사 후 포커스 이동 ( class component ) (0) | 2022.11.17 |
[React-Native] 키보드에 하단 TabBar 숨기기 (0) | 2022.11.17 |