Skip to content

Commit 626362e

Browse files
refactor: convert AnyOfField from class to functional component (#5139)
* refactor(core): convert AnyOfField from class to functional component Replaces the class-based AnyOfField with a functional component using useReducer for state management. State snapshots (prevOptions, prevFormData, prevFieldId) replace the three useRef prev-trackers and useEffect, using React's getDerivedStateFromProps render-phase dispatch pattern instead — React re-renders immediately from those dispatches and discards the current render before any DOM commit. onOptionChange is wrapped in useCallback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(core): simplify AnyOfField state — useMemo + useState + useEffect Replaces the render-phase dispatch pattern (getDerivedStateFromProps) with conventional hooks: retrievedOptions moves to useMemo (pure derivation from options/formData/schemaUtils), selectedOption becomes plain useState, and the auto-matching logic returns to a post-render useEffect mirroring componentDidUpdate. Removes AnyOfFieldState, AnyOfFieldAction, and anyOfFieldReducer entirely. Including formData in useMemo deps also fixes a latent bug where retrieved option schemas could be stale for formData- conditional $refs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * - Replaced Object.is() comparison of `formData` with string comparison --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bdd2907 commit 626362e

1 file changed

Lines changed: 201 additions & 241 deletions

File tree

0 commit comments

Comments
 (0)