lxbme opened a new pull request, #3446:
URL: https://github.com/apache/apisix-dashboard/pull/3446

   Please answer these questions before submitting a pull request, **or your PR 
will get closed**.
   
   **Why submit this pull request?**
   
   - [x] Bugfix
   - [x] Improve performance
   
   **What changes will this PR take into?**
   
   This addresses the "MobX toolchain held hostage by one component" item of 
the frontend review in #3417.
   
   `mobx-react-observer`'s SWC plugin was wired into the build 
(`vite.config.ts`), which wraps **every** component in the app in `observer()` 
at compile time — an app-wide transform whose only purpose was to make a single 
`useLocalObservable` search filter in `PluginCardList.tsx` reactive. 
`mobx-persist-store` was a dependency with zero imports.
   
   Changes:
   
   - **`PluginCardList.tsx`** — the local observable only mirrored the 
component's own props (`search`, `plugins`, `mode`) back into itself via three 
`useEffect`s, then exposed a `list` getter that filtered `plugins` by `search`. 
Replaced with a single `useMemo`, which is exactly equivalent (and drops the 
three mirror effects). The observable's `list` getter also captured 
`onAdd`/`onEdit`/… from the first render's closure; the `useMemo` lists them as 
dependencies, so the handlers are now always current.
   - **`vite.config.ts`** — removed the `mobx-react-observer/swc-plugin` import 
and its use in the React SWC plugin, so components are no longer wrapped 
app-wide. This is safe because that `useLocalObservable` was the only MobX 
observable in `src/` (no `makeObservable`/`observable`/`observer()`/`autorun` 
anywhere), so nothing else depends on the auto-wrapping.
   - **`package.json`** — removed the now-unused `mobx`, `mobx-react-lite`, and 
`mobx-react-observer`, plus the never-imported `mobx-persist-store`.
   
   **Related issues**
   
   Part of #3417
   
   **Checklist:**
   
   - [x] Did you explain what problem does this PR solve? Or what new features 
have been added?
   - [ ] Have you added corresponding test cases?
   - [x] Have you modified the corresponding document?
   - [x] Is this PR backward compatible? If it is not backward compatible, 
please discuss on the mailing list first
   
   The plugin-card list's behaviour is unchanged; no new tests were added for 
the like-for-like refactor. The searchable plugin list (the migrated component) 
was verified manually in a production-like build — typing `limit` narrows 106 
plugins to the 5 whose names contain it, a non-matching query shows "No Data", 
and clearing restores the full list. Verified with `tsc`, ESLint, the unit 
suite, and the full e2e suite.
   


-- 
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]

Reply via email to