Skip to content

Commit

Permalink
removed no-op set state (#703)
Browse files Browse the repository at this point in the history
Co-authored-by: Talha Naqvi <talha.naqvi@shopify.com>
  • Loading branch information
naqvitalha and naqvitalha authored Mar 29, 2022
1 parent ca0e89a commit 3d581db
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
private _virtualRenderer: VirtualRenderer;
private _onEndReachedCalled = false;
private _initComplete = false;
private _isMounted = true;
private _relayoutReqIndex: number = -1;
private _params: RenderStackParams = {
initialOffset: 0,
Expand Down Expand Up @@ -242,6 +243,7 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
}

public componentWillUnmount(): void {
this._isMounted = false;
if (this.props.contextProvider) {
const uniqueKey = this.props.contextProvider.getUniqueKey();
if (uniqueKey) {
Expand Down Expand Up @@ -546,9 +548,11 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends

private _queueStateRefresh(): void {
this.refreshRequestDebouncer(() => {
this.setState((prevState) => {
return prevState;
});
if (this._isMounted) {
this.setState((prevState) => {
return prevState;
});
}
});
}

Expand Down

0 comments on commit 3d581db

Please sign in to comment.