Fix render-phase dispatch in FieldArrayForm

This commit is contained in:
2026-04-07 12:37:29 +01:00
parent 503a0b5b9a
commit dcdec08f6d
2 changed files with 32 additions and 2 deletions
+26
View File
@@ -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.