Commit 6cb8b59
committed
fix(FR-2815): break ResourceAllocationFormItems render loop with idempotent guards
Resolves #7248(FR-2815)
User reported the 'use memo' directive alone did not stop the loop on rc2.
Deeper analysis shows the loop is closed by `setFieldsValue` calls that
repeatedly write the same value, which still notifies subscribers (including
the page-level `Form.useWatch('resource')` added in FR-2324) and triggers a
parent re-render, forcing the child to re-render and re-fire the effect.
Fixes:
1. Wrap `acceleratorSlotsInRG = _.omitBy(...)` in an explicit `useMemo` with
`[resourceSlotsInRG]` deps, so its identity is stable across renders even
if the React Compiler does not memoize it. This stabilizes the downstream
`supportedAcceleratorTypesInRGByImage` useMemo.
2. Add idempotent guards to the `useEffect` at line 226 so `setFieldsValue`
is only called when the target value actually differs:
- Skip `allocationPreset: 'auto-select'` write when it is already
'auto-select' or 'custom'.
- Skip `resource.accelerator: 0` write when it is already `0`.
3. Add an idempotent early-return to `ensureValidAcceleratorType` when the
target accelerator type equals the current one. This helper is called
unconditionally from another effect at line 460-515; without the guard
it pump-primes the same loop.
Kept the `'use memo'` directives from the prior commit on this branch as
they align with the project-wide React 19.2 + React Compiler convention
(`.claude/rules/react-compiler-memoization.md`).1 parent 00572ee commit 6cb8b59
2 files changed
Lines changed: 38 additions & 9 deletions
File tree
- react/src
- components/SessionFormItems
- hooks
Lines changed: 37 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
191 | 201 | | |
192 | 202 | | |
193 | 203 | | |
| |||
223 | 233 | | |
224 | 234 | | |
225 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
226 | 242 | | |
227 | 243 | | |
228 | | - | |
| 244 | + | |
| 245 | + | |
229 | 246 | | |
230 | 247 | | |
231 | 248 | | |
232 | 249 | | |
233 | 250 | | |
234 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
235 | 255 | | |
236 | 256 | | |
237 | 257 | | |
| |||
278 | 298 | | |
279 | 299 | | |
280 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
281 | 309 | | |
282 | 310 | | |
283 | | - | |
| 311 | + | |
284 | 312 | | |
285 | 313 | | |
286 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
0 commit comments