Skip to content

Commit

Permalink
Fix header refreshing, remove lib react-fast-compare
Browse files Browse the repository at this point in the history
  • Loading branch information
letrungduong113 committed May 12, 2021
1 parent cb39896 commit ab5a792
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/RefreshFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {memo} from 'react';
import isEqual from 'react-fast-compare';
import {
ActivityIndicator,
StyleSheet,
Expand Down Expand Up @@ -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: {
Expand Down
10 changes: 3 additions & 7 deletions src/RefreshListView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {Component} from 'react';
import isEqual from 'react-fast-compare';
import React, {PureComponent} from 'react';
import {
FlatList,
FlatListProps,
Expand Down Expand Up @@ -46,7 +45,7 @@ type State = {
footerState: RefreshState;
};
let callOnScrollEnd = false;
export default class RefreshListView<ItemT> extends Component<
export default class RefreshListView<ItemT> extends PureComponent<
Props<ItemT>,
State
> {
Expand Down Expand Up @@ -75,9 +74,6 @@ export default class RefreshListView<ItemT> 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) {
Expand Down Expand Up @@ -160,7 +156,7 @@ export default class RefreshListView<ItemT> extends Component<

if (callOnScrollEnd && this.shouldStartFooterRefreshing()) {
if (offsetY + height >= contentHeight) {
// console.log('load more');
// console.log("load more");
this.startFooterRefreshing();
callOnScrollEnd = false;
}
Expand Down

0 comments on commit ab5a792

Please sign in to comment.