IA-985: Perf: Memoize educationLevelOptions, subjectOptions, and chapterOptions in AIAssistantForm
Summary
Minor performance improvement in the AIAssistantForm component to avoid unnecessary re-computation of derived arrays on every render.
Changes
AIAssistantForm
- Added
useMemoimport - Wrapped
educationLevelOptions,subjectOptions, andchapterOptionswithuseMemoso they are only recomputed when their source arrays (levels,localSubjects,localChapters) actually change
Why
These three arrays were previously recomputed on every render, which could cause unnecessary re-renders of child components (e.g. Select / MenuItem lists) since they received new array references each time, even when the underlying data hadn't changed.