Skip to content

Commit

Permalink
change didSubscribeToReportLeavingEvents check to early return
Browse files Browse the repository at this point in the history
  • Loading branch information
wildan-m committed Sep 20, 2023
1 parent 8926377 commit b2303b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ function ReportScreen({
fetchReportIfNeeded();
ComposerActions.setShouldShowComposeInput(true);
return () => {
if (didSubscribeToReportLeavingEvents) {
Report.unsubscribeFromLeavingRoomReportChannel(report.reportID);
if (!didSubscribeToReportLeavingEvents) {
return;
}

Report.unsubscribeFromLeavingRoomReportChannel(report.reportID);
};

// I'm disabling the warning, as it expects to use exhaustive deps, even though we want this useEffect to run only on the first render.
Expand Down

0 comments on commit b2303b2

Please sign in to comment.