mirror of
https://github.com/KelvinTegelaar/CIPP.git
synced 2026-04-25 00:06:06 +03:00
[GH-ISSUE #5454] useEffect bloat refactor: extract data transforms and add validation guards #2628
Labels
No labels
API
Feature
NotABug
NotABug
Planned
Sponsor Priority
Sponsor Priority
bug
documentation
duplicate
enhancement
needs more info
no-activity
no-priority
not-assigned
pull-request
react-conversion
react-conversion
roadmap
security
stale
unconfirmed-by-user
unconfirmed-by-user
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/CIPP#2628
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @redanthrax on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/5454
Required confirmations before submitting
Issue Description
Summary
Several edit components in CIPP have
useEffecthooks doing too much work inline —data transformation, state updates, and form resets all in a single block.
This makes them hard to read and introduces subtle bugs (missing validation
triggers, no stale-closure guards).
contacts/edit.jsxalready implements the correct pattern and should betreated as the reference implementation for this refactor.
Affected Files
src/pages/identity/administration/groups/edit.jsx— HIGH PRIORITYIssues:
useEffectdoes 4 things: builds membership table data,classifies group type (inline IIFE), sets initial values for change
detection, and resets the form. This should be split.
groupTypeclassification runs synchronously insidethe effect — should be a
useMemo.setCombinedData()andsetInitialValues()called in the same effectas
formControl.reset()— causes unnecessary batched re-renders.formControl.trigger()afterreset()— form appears valid on loadeven if loaded data violates field constraints.
Suggested fix:
src/pages/email/resources/management/list-rooms/edit.jsx— MEDIUM PRIORITYIssues:
formControl.reset()payload built inline insideuseEffect—the data transform (timezone lookup, country lookup, tags mapping)
should be extracted to
useMemo.void formControl.trigger()present (good) but no stale-closure guard— if the component unmounts while trigger is in-flight, the resolved
promise touches dead state.
Suggested fix:
Reference Implementation
src/pages/email/administration/contacts/edit.jsxalready does this correctly:useMemo(processedContactData)useCallback(resetForm)useEffectbody is a single line:resetForm()Mapfor O(1) country lookupThis file should be the template for the above refactors.
Impact
the same effect
Environment Type
Sponsored (paying) user
Front End Version
latest
Back End Version
latest
Relevant Logs / Stack Trace
@github-actions[bot] commented on GitHub (Feb 24, 2026):
Thank you for reporting a potential bug. If you would like to work on this bug, please comment:
Thank you for helping us maintain the project!