Fix render-phase dispatch in FieldArrayForm
This commit is contained in:
@@ -3473,3 +3473,29 @@ Validation:
|
||||
Follow-ups:
|
||||
|
||||
- Keep redux-form `fields.push/remove` calls event/effect-driven (not render-driven) in future slices.
|
||||
|
||||
---
|
||||
|
||||
### CL-097: 22500 `FieldArrayForm` render-phase dispatch warning hotfix
|
||||
|
||||
date: 2026-04-07
|
||||
author: Cline
|
||||
scope: `components/elements/index.js`
|
||||
type: change
|
||||
rationale: Fix React warning caused by dispatching redux-form state updates during `FieldArrayForm` render.
|
||||
impact: No intended behavior change; clearing hidden FieldArray values remains intact but now executes in effect phase instead of render phase.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- Root cause: `dispatch(change("appealForm", name, null))` was called inline in render when parent condition was false.
|
||||
- Fix: moved that dispatch into `useEffect` guarded by `!showIfHasParentShowValue`.
|
||||
- Added `useEffect` import in `components/elements/index.js`.
|
||||
|
||||
Validation:
|
||||
|
||||
- `npx eslint components/elements/index.js` -> pass
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- Continue avoiding dispatch/state mutations inside render for field visibility toggles.
|
||||
|
||||
Reference in New Issue
Block a user