Skip to content

(fix) Reduce re-render churn in FormProcessorFactory#670

Open
ibacher wants to merge 5 commits intomainfrom
fix/improve-context-rerenders
Open

(fix) Reduce re-render churn in FormProcessorFactory#670
ibacher wants to merge 5 commits intomainfrom
fix/improve-context-rerenders

Conversation

@ibacher
Copy link
Member

@ibacher ibacher commented Dec 3, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

In the FormProcessorFactory, there's serious potential for render cascades from the combinations of useEffect() and setState() that then trigger additional useEffect() and setState() calls. This PR switches to more aggressively caching some of these key hooks so that there's less potential for these cascade to lead to catastrophic reloading issues.

Secondary to that, this also tries to make the processorContext more stable by essentially dividing it into parts that are set by the FormProcessorFactory (the "static" parts) and parts that are set by child hooks and components (the "mutable" parts). This, hopefully, should reduce the render churn in downstream components.

Unrelatedly, this sets a fixed timezone for tests, as the current batch fail in UTC negative timezones like the US east coast.

Screenshots

Related Issue

Other

…e churn

In the FormProcessorFactory, there's serious potential for render
cascades from the combinations of `useEffect()` and `setState()` that
then trigger additional `useEffect()` and `setState()` calls. This
commit switches to more aggressively caching some of these key hooks so
that there's less potential for these cascade to lead to catastrophic
reloading issues.
This is basically done by splitting the processor context into a "static"
part that is derived from the form itself and a "dynamic" part that may
be updated by components downstream of the FormProcessorFactory. This
mostly should optimize things so that components that depend on the
processor context should mostly get stable objects, assuming they
correctly use the properties of the processor.
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

Size Change: +246 B (+0.02%)

Total Size: 1.42 MB

ℹ️ View Unchanged
Filename Size Change
dist/177.js 5.13 kB 0 B
dist/225.js 256 B 0 B
dist/255.js 5.78 kB 0 B
dist/327.js 1.9 kB 0 B
dist/353.js 3.02 kB 0 B
dist/41.js 1.53 kB 0 B
dist/422.js 1.53 kB 0 B
dist/435.js 137 kB 0 B
dist/449.js 271 kB +246 B (+0.09%)
dist/540.js 2.64 kB 0 B
dist/606.js 256 B 0 B
dist/635.js 13.2 kB 0 B
dist/708.js 1.52 kB 0 B
dist/747.js 454 kB 0 B
dist/759.js 62.5 kB 0 B
dist/796.js 486 B 0 B
dist/main.js 450 kB 0 B
dist/openmrs-esm-form-engine-lib.js 3.72 kB 0 B

compressed-size-action

…ent.tsx

Co-authored-by: Dennis Kigen <kigen.work@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants