Altinn / app-frontend-react

Altinn application React frontend
BSD 3-Clause "New" or "Revised" License
18 stars 31 forks source link

Performance fixes that improved ra0692-01 #2732

Closed olemartinorg closed 5 days ago

olemartinorg commented 5 days ago

Description

A few minor fixes to make the upcoming ssb/ra0692-01 more tolerable. This form has very many components, possibly with dynamic behaviour, and simply setting data in the NodesContext is noticably slow (presumably because all selectors have to re-run).

  1. Removed an undefined class in src/features/alertOnChange/DeleteWarningPopover.tsx
  2. Making useLookupBinding() static. This didn't really need to re-render when DataModelsProvider changes(?). I didn't really look into the root cause for this, but I observed that <DataModelValidation /> re-rendered for all nodes when clicking a checkbox (which in turn added a row to a repeating group).
  3. When multiple new components were discovered in the node generator, these would all call the restart() function. This only caused {} to be set in the NodesContext. This seems harmless, but it turns out setting an empty object still means all selects have to re-run, so this contributed to a very noticable slowdown when adding a row to a repeating group (which adds multiple new components).

Sadly, this form is far from optimal after these fixes, but they're low-hanging fruit.

Related Issue(s)

Verification/QA

sonarcloud[bot] commented 5 days ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud