From ab5a7922e770f3027c5fdd14aa90c43552c42672 Mon Sep 17 00:00:00 2001 From: DuongLT Date: Wed, 12 May 2021 23:09:31 +0700 Subject: [PATCH] Fix header refreshing, remove lib react-fast-compare --- example/package.json | 2 +- src/RefreshFooter.tsx | 3 +-- src/RefreshListView.tsx | 10 +++------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/example/package.json b/example/package.json index cb08544..e4ae211 100644 --- a/example/package.json +++ b/example/package.json @@ -10,7 +10,7 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { - "flatlist-view-control-rn": "^1.0.3", + "flatlist-view-control-rn": "^1.0.4", "immer": "^9.0.2", "react": "17.0.1", "react-native": "0.64.0", diff --git a/src/RefreshFooter.tsx b/src/RefreshFooter.tsx index cc76bad..a9b94d6 100644 --- a/src/RefreshFooter.tsx +++ b/src/RefreshFooter.tsx @@ -1,5 +1,4 @@ import React, {memo} from 'react'; -import isEqual from 'react-fast-compare'; import { ActivityIndicator, StyleSheet, @@ -93,7 +92,7 @@ RefreshFooter.defaultProps = { footerLoadMoreText: 'Pull up to load more', }; -export default memo(RefreshFooter, isEqual); +export default memo(RefreshFooter); const styles = StyleSheet.create({ loadingView: { diff --git a/src/RefreshListView.tsx b/src/RefreshListView.tsx index 9789ab5..3ab613a 100644 --- a/src/RefreshListView.tsx +++ b/src/RefreshListView.tsx @@ -1,5 +1,4 @@ -import React, {Component} from 'react'; -import isEqual from 'react-fast-compare'; +import React, {PureComponent} from 'react'; import { FlatList, FlatListProps, @@ -46,7 +45,7 @@ type State = { footerState: RefreshState; }; let callOnScrollEnd = false; -export default class RefreshListView extends Component< +export default class RefreshListView extends PureComponent< Props, State > { @@ -75,9 +74,6 @@ export default class RefreshListView extends Component< footerState: RefreshState.Idle, // The current state of the tail, the default is Idle, no controls are displayed }; } - shouldComponentUpdate(nextProps: any) { - return !isEqual(this.props, nextProps); - } public scrollToIndex = (index: number) => { if (this.listRef && this.props.data && this.props.data.length > 0) { @@ -160,7 +156,7 @@ export default class RefreshListView extends Component< if (callOnScrollEnd && this.shouldStartFooterRefreshing()) { if (offsetY + height >= contentHeight) { - // console.log('load more'); + // console.log("load more"); this.startFooterRefreshing(); callOnScrollEnd = false; }