Skip to content

Commit ab5a792

Browse files
Fix header refreshing, remove lib react-fast-compare
1 parent cb39896 commit ab5a792

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
1111
},
1212
"dependencies": {
13-
"flatlist-view-control-rn": "^1.0.3",
13+
"flatlist-view-control-rn": "^1.0.4",
1414
"immer": "^9.0.2",
1515
"react": "17.0.1",
1616
"react-native": "0.64.0",

src/RefreshFooter.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, {memo} from 'react';
2-
import isEqual from 'react-fast-compare';
32
import {
43
ActivityIndicator,
54
StyleSheet,
@@ -93,7 +92,7 @@ RefreshFooter.defaultProps = {
9392
footerLoadMoreText: 'Pull up to load more',
9493
};
9594

96-
export default memo(RefreshFooter, isEqual);
95+
export default memo(RefreshFooter);
9796

9897
const styles = StyleSheet.create({
9998
loadingView: {

src/RefreshListView.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React, {Component} from 'react';
2-
import isEqual from 'react-fast-compare';
1+
import React, {PureComponent} from 'react';
32
import {
43
FlatList,
54
FlatListProps,
@@ -46,7 +45,7 @@ type State = {
4645
footerState: RefreshState;
4746
};
4847
let callOnScrollEnd = false;
49-
export default class RefreshListView<ItemT> extends Component<
48+
export default class RefreshListView<ItemT> extends PureComponent<
5049
Props<ItemT>,
5150
State
5251
> {
@@ -75,9 +74,6 @@ export default class RefreshListView<ItemT> extends Component<
7574
footerState: RefreshState.Idle, // The current state of the tail, the default is Idle, no controls are displayed
7675
};
7776
}
78-
shouldComponentUpdate(nextProps: any) {
79-
return !isEqual(this.props, nextProps);
80-
}
8177

8278
public scrollToIndex = (index: number) => {
8379
if (this.listRef && this.props.data && this.props.data.length > 0) {
@@ -160,7 +156,7 @@ export default class RefreshListView<ItemT> extends Component<
160156

161157
if (callOnScrollEnd && this.shouldStartFooterRefreshing()) {
162158
if (offsetY + height >= contentHeight) {
163-
// console.log('load more');
159+
// console.log("load more");
164160
this.startFooterRefreshing();
165161
callOnScrollEnd = false;
166162
}

0 commit comments

Comments
 (0)