-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Problem
The Profiler indicates that the ReportScreen render time gets re-rendered dozens of times, with each re-rendering taking an average of 599.8ms.
The most current problems are with this hook:
const lastAccessedReportID = useLastAccessedReportID(!!route.params.openOnAdminRoom);
In this PR we’ve introduced the above hook and there might be several problems with it:
- We are calculating
lastAccessedReportIDin each re-render, however, we only require it in one particular scenario: when theroute.params.reportIDis empty, - The
useLastAccessedReportIDhook is heavy, due to the poor performance of theReportUtils.findLastAccessedReportfunction. This issue existed before the introduction of the PR mentioned.
Solution
Ad 1.
We should calculate the lastAccessedReportID only when needed, that means only once, and only when route.params.reportID is empty (code). This value is used to determine which chat we should show to the user when the user accesses the website without reportID in the URL. POC
Ad 2.
After diving deep into the code I’ve discovered that we sort a whole array of reports just to get one, the most recent, report. We can replace this sort with lodashMaxBy, as we do not (from my analysis) need to sort all reports (needs confirmation). POC
cc @kosmydel
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~0109e0b5642eb1863c
- Upwork Job ID: 1809262837407973619
- Last Price Increase: 2024-07-05
- Automatic offers:
- ikevin127 | Reviewer | 103028165
Issue Owner
Current Issue Owner: @zanyrenneyMetadata
Metadata
Assignees
Labels
Type
Projects
Status