hussnainahmedd opened a new pull request, #706: URL: https://github.com/apache/shenyu-dashboard/pull/706
Closes #607 ## What was wrong In `src/routes/Plugin/AiProxy/ApiKeys/index.js`, the `columns` memo was built with `useMemo(..., [namespaceId, onToggle])` while `onToggle` was declared later via `const`. After Babel transpiles `const` to `var`, the dependency slot evaluates to `undefined` on every render, so `columns` was never recomputed when it should be — the memoized `Switch`/`Popconfirm` renderers kept the **first render's** `page`, `pageSize`, `queryKey` and `selectorId`. **User-visible symptom:** go to page 2 (or apply a filter) and flip an "Enabled" switch — the refetch goes out with page 1 and no filter while the pager still shows page 2, so the table and pager disagree. ## Fix - Declared `fetchList`, `onToggle` and `onBatchDelete` **before** the `useMemo`, each wrapped in `useCallback` with complete dependency arrays (`fetchList` tracks `selectorId, namespaceId, page, pageSize, queryKey`; the other two track `selectorId, fetchList`). - Added the previously-missing `onBatchDelete` to the `columns` dependency array (same stale-closure class of bug). No behavior change other than the handlers now seeing current state. Single file, +40/−29. ## Validation - `node --check` passes on the file. - ESLint reports 0 errors/warnings on the file. - Static verification: all three handlers are `useCallback`s declared before the `columns` `useMemo`; no leftover plain declarations; dependency arrays cover every changing input used in the bodies. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
