Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed no-op set state #703

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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