Skip to content

Comments

refactor: Replace useMountMergeState with useMergedState #9383

Merged
chenshuai2144 merged 1 commit intoant-design:masterfrom
zzjiaxiang:remove-old-api
Jan 14, 2026
Merged

refactor: Replace useMountMergeState with useMergedState #9383
chenshuai2144 merged 1 commit intoant-design:masterfrom
zzjiaxiang:remove-old-api

Conversation

@zzjiaxiang
Copy link
Contributor

@zzjiaxiang zzjiaxiang commented Jan 8, 2026

about
同时删除了 项目里面的 useMountMergeState 改为统一从 @rc-component/util 导入

Summary by CodeRabbit

重构

  • 优化了内部状态管理机制,提升代码可维护性和一致性
  • 清理了模块导入和导出结构,删除不再使用的内部工具
  • 调整代码格式,无功能性变化

✏️ Tip: You can customize this high-level summary in your review settings.

…nents

This commit updates various components to replace the deprecated useMountMergeState hook with the new useMergedState hook from @rc-component/util. The changes enhance consistency and maintainability in state management across the codebase. Additionally, some imports have been cleaned up to remove unnecessary references to the removed useMountMergeState utility.
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 8, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

该PR将自定义的useMountMergeState钩子迁移至来自@rc-component/util的标准钩子(useMergedStateuseControlledStateuseState),涵盖卡片、表单、布局和表格组件,同时清理导入重复和更新API导出。

Changes

Cohort / File(s) 变更摘要
卡片组件 CheckCard
src/card/components/CheckCard/Group.tsx, src/card/components/CheckCard/index.tsx
useMountMergeState替换为useMergedState进行状态初始化,保持行为不变
字段选择组件
src/field/components/Select/index.tsx, src/field/components/Select/SearchSelect/index.tsx
使用useControlledState管理选项状态,调整初始化逻辑;接口声明格式调整
表单基础组件
src/form/BaseForm/BaseForm.tsx, src/form/BaseForm/LightWrapper/index.tsx
加载状态从useMountMergeState切换至useMergedStateuseState
表单项组件
src/form/components/FormItem/FormItemRender/index.tsx, src/form/components/FormItem/Group/index.tsx, src/form/components/Text/index.tsx
折叠/值状态从useMountMergeState替换为useMergedState;类型参数格式化调整
表单查询过滤
src/form/layouts/QueryFilter/index.tsx
宽度状态从useMountMergeState改用useState;添加并整合RcResizeObserver导入
布局组件
src/layout/ProLayout.tsx, src/layout/components/GlobalHeader/ActionsContent.tsx, src/layout/components/PageHeader/index.tsx, src/layout/components/SiderMenu/BaseMenu.tsx
菜单加载和键值状态改用useMergedStateuseState;消除ResizeObserver导入重复
表格核心
src/table/Table.tsx, src/table/useFetchData.tsx
选中行键、表单搜索、过滤排序状态改用useControlledStateuseState;数据列表和分页状态用useMergedState
表格辅助组件
src/table/TableRender.tsx, src/table/TableSearch.tsx, src/table/TableToolbar.tsx, src/table/components/ListToolBar/index.tsx
导入整理、格式调整;添加类型导入;消除ResizeObserver导入重复
工具函数
src/utils/index.tsx, src/utils/useMountMergeState/index.ts, src/utils/useEditableArray/index.tsx
删除useMountMergeState导出和公共别名;编辑数组操作改用useState
测试配置
vitest.config.mts
从覆盖率排除列表移除useMountMergeState相关路径

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Poem

🐰 钩子的迁移之路,
从自制到标准库,
useMergedState 换新颜,
useControlledState 来相助,
useState 的简洁之美,
代码焕新,逻辑依旧。

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次拉取请求的主要变更,即用 useMergedState 替换 useMountMergeState。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zzjiaxiang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求通过标准化状态管理钩子对代码库进行了重构。它将项目中原有的自定义 useMountMergeState 钩子替换为来自 @rc-component/util 库中更健壮且外部维护的 useMergedStateuseControlledState。这一改变通过集中化工具钩子并移除其本地重复实现,简化了卡片、表单、布局和表格等各种组件中的状态管理逻辑。

Highlights

  • 统一状态管理钩子: 将项目中自定义的 useMountMergeState 钩子替换为来自 @rc-component/util 包的 useMergedStateuseControlledState
  • 移除本地实现: 删除了项目内部的 src/utils/useMountMergeState 文件及其所有引用,实现了状态管理逻辑的集中化。
  • 优化代码结构: 通过统一使用外部库提供的钩子,减少了项目内部的重复实现,提高了代码的一致性和可维护性。
  • 广泛应用: 此替换操作涉及 CheckCardSelectBaseFormQueryFilterProLayoutSiderMenuProTable 等多个核心组件。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the 🧱 antd label Jan 8, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这是一个很棒的重构 PR,将项目内的 useMountMergeState 替换为从 @rc-component/util 导入的钩子函数。这提高了代码的一致性和可维护性。

我注意到代码中同时使用了 useMergedStateuseControlledState。根据上游库 rc-component/util 的更新,useControlledStateuseMergedState 新的推荐名称。为了保持一致性,我建议在整个项目中统一使用 useControlledState。我在几个文件中留下了修改建议。

]);

const [stateValue, setStateValue] = useMountMergeState<
const [stateValue, setStateValue] = useMergedState<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledStateuseControlledStateuseMergedState 新的别名,使用新名称可以提高代码的可读性和未来维护性。同时请记得更新文件顶部的 import 语句:import { omit, useControlledState } from '@rc-component/util';

Suggested change
const [stateValue, setStateValue] = useMergedState<
const [stateValue, setStateValue] = useControlledState<

Group: typeof CheckCardGroup;
} = (props) => {
const [stateChecked, setStateChecked] = useMountMergeState<boolean>(
const [stateChecked, setStateChecked] = useMergedState<boolean>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledState。同时请记得更新文件顶部的 import 语句:import { useControlledState } from '@rc-component/util';

Suggested change
const [stateChecked, setStateChecked] = useMergedState<boolean>(
const [stateChecked, setStateChecked] = useControlledState<boolean>(

} = props;
const formRef = useRef<ProFormRef<any>>({} as any);
const [loading, setLoading] = useMountMergeState<boolean>(false, {
const [loading, setLoading] = useMergedState<boolean>(false, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledState。同时请记得更新文件顶部的 import 语句。

Suggested change
const [loading, setLoading] = useMergedState<boolean>(false, {
const [loading, setLoading] = useControlledState<boolean>(false, {

};

const [collapsed, setCollapsed] = useMountMergeState(
const [collapsed, setCollapsed] = useMergedState(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledState。同时请记得更新文件顶部的 import 语句:import { useControlledState } from '@rc-component/util';

Suggested change
const [collapsed, setCollapsed] = useMergedState(
const [collapsed, setCollapsed] = useControlledState(

}
> = (props) => {
const [open, setOpen] = useMountMergeState<boolean>(props.open || false, {
const [open, setOpen] = useMergedState<boolean>(props.open || false, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledState。同时请记得更新文件顶部的 import 语句:import { omit, useControlledState } from '@rc-component/util';

Suggested change
const [open, setOpen] = useMergedState<boolean>(props.open || false, {
const [open, setOpen] = useControlledState<boolean>(props.open || false, {

const prefixCls = props.prefixCls ?? context.getPrefixCls('pro');

const [menuLoading, setMenuLoading] = useMountMergeState(false, {
const [menuLoading, setMenuLoading] = useMergedState(false, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledState。同时请记得更新文件顶部的 import 语句。

Suggested change
const [menuLoading, setMenuLoading] = useMergedState(false, {
const [menuLoading, setMenuLoading] = useControlledState(false, {

const [openKeys, setOpenKeys] = useMountMergeState<
(string | number)[] | false
>(
const [openKeys, setOpenKeys] = useMergedState<(string | number)[] | false>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledStateuseControlledStateuseMergedState 新的别名,使用新名称可以提高代码的可读性和未来维护性。此文件中的其他 useMergedState(L593)也建议一并修改。同时请记得更新文件顶部的 import 语句:import { useControlledState } from '@rc-component/util';

Suggested change
const [openKeys, setOpenKeys] = useMergedState<(string | number)[] | false>(
const [openKeys, setOpenKeys] = useControlledState<(string | number)[] | false>(

* 用于存储最新的数据,这样可以在切换的时候保持数据的一致性
*/
const [tableDataList, setTableDataList] = useMountMergeState<
const [tableDataList, setTableDataList] = useMergedState<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了与上游库 @rc-component/util 的最新推荐保持一致,建议将 useMergedState 替换为 useControlledStateuseControlledStateuseMergedState 新的别名,使用新名称可以提高代码的可读性和未来维护性。此文件中的其他 useMergedState(L94, L110)也建议一并修改。同时请记得更新文件顶部的 import 语句:import { useControlledState } from '@rc-component/util';

Suggested change
const [tableDataList, setTableDataList] = useMergedState<
const [tableDataList, setTableDataList] = useControlledState<

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/table/useFetchData.tsx (1)

103-115: 注释内容与代码职责混淆。

Line 103 的注释将 PageInfo 类型定义与 useMergedState 钩子实现细节混在一起,降低了代码可读性。建议将注释聚焦于 PageInfo 类型本身,避免提及具体的钩子实现:

♻️ 建议优化注释内容
  /**
-  * 表示页面信息的类型  useMergedState 钩子的初始值和参数
+  * 表示页面信息的类型
   * @typedef {object} PageInfo
   * @property {number} current 当前页码
   * @property {number} pageSize 页面大小
   * @property {number} total 数据总量
-  * @type {[PageInfo, React.Dispatch<React.SetStateAction<PageInfo>>]}
   */
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6113b0 and 3ad2ce9.

📒 Files selected for processing (24)
  • src/card/components/CheckCard/Group.tsx
  • src/card/components/CheckCard/index.tsx
  • src/field/components/Select/SearchSelect/index.tsx
  • src/field/components/Select/index.tsx
  • src/form/BaseForm/BaseForm.tsx
  • src/form/BaseForm/LightWrapper/index.tsx
  • src/form/components/FormItem/FormItemRender/index.tsx
  • src/form/components/FormItem/Group/index.tsx
  • src/form/components/Text/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/layout/ProLayout.tsx
  • src/layout/components/GlobalHeader/ActionsContent.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
  • src/table/Table.tsx
  • src/table/TableRender.tsx
  • src/table/TableSearch.tsx
  • src/table/TableToolbar.tsx
  • src/table/components/ListToolBar/index.tsx
  • src/table/useFetchData.tsx
  • src/utils/index.tsx
  • src/utils/useEditableArray/index.tsx
  • src/utils/useMountMergeState/index.ts
  • vitest.config.mts
💤 Files with no reviewable changes (3)
  • src/utils/index.tsx
  • src/utils/useMountMergeState/index.ts
  • vitest.config.mts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.{tsx,jsx}: Use early returns whenever possible to make the code more readable.
Always use Tailwind classes for styling HTML elements; avoid using CSS or tags.
Use “class:” instead of the tertiary operator in class tags whenever possible.
Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.
Use consts instead of functions, for example, “const toggle = () =>”. Also, define a type if possible.

Files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/layout/components/GlobalHeader/ActionsContent.tsx
  • src/table/TableRender.tsx
  • src/form/components/Text/index.tsx
  • src/utils/useEditableArray/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/field/components/Select/index.tsx
  • src/card/components/CheckCard/Group.tsx
  • src/layout/ProLayout.tsx
  • src/field/components/Select/SearchSelect/index.tsx
  • src/table/useFetchData.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/card/components/CheckCard/index.tsx
  • src/table/Table.tsx
  • src/form/BaseForm/BaseForm.tsx
  • src/form/components/FormItem/Group/index.tsx
  • src/table/components/ListToolBar/index.tsx
  • src/table/TableToolbar.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
  • src/form/components/FormItem/FormItemRender/index.tsx
  • src/table/TableSearch.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/AGENTS.md)

**/*.{ts,tsx}: Use TypeScript and React for development
Use early returns to improve code readability
Use camelCase for property names
Props naming: Use default + PropName for initialization properties
Props naming: Use forceRender for forced rendering
Props naming: Use force + SubComponentName + Render for sub-component forced rendering
Props naming: Use SubComponentName + Render for sub-component rendering
Props naming: Use dataSource for data sources
Props naming: Use open instead of visible for panel opening state
Props naming: Use show + PropName for display-related properties
Props naming: Use PropName + able for functional properties
Props naming: Use disabled for disabled state
Props naming: Use extra for additional content
Props naming: Use icon for icons
Props naming: Use trigger for triggers
Props naming: Use className for class names
Event naming: Use on + EventName for triggering events
Event naming: Use on + SubComponentName + EventName for sub-component events
Event naming: Use before + EventName for pre-action events
Event naming: Use after + EventName for post-action events
Event naming: Use on + EventName + Complete for continuous action completion
All components and functions must provide accurate type definitions
Avoid using any type, define types as precisely as possible
Use interface rather than type alias for defining object structures
Strictly follow TypeScript type design principles to ensure type safety
Ensure compilation without any type errors or warnings
Component props should be defined using interface for extensibility
Component props interface naming should follow ComponentNameProps convention
Define specialized interfaces for component state, such as ComponentNameState
Complex data structures should be split into multiple interface definitions
All callback function types should explicitly define parameters and return values
Appropriately use generics to enhance t...

Files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/layout/components/GlobalHeader/ActionsContent.tsx
  • src/table/TableRender.tsx
  • src/form/components/Text/index.tsx
  • src/utils/useEditableArray/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/field/components/Select/index.tsx
  • src/card/components/CheckCard/Group.tsx
  • src/layout/ProLayout.tsx
  • src/field/components/Select/SearchSelect/index.tsx
  • src/table/useFetchData.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/card/components/CheckCard/index.tsx
  • src/table/Table.tsx
  • src/form/BaseForm/BaseForm.tsx
  • src/form/components/FormItem/Group/index.tsx
  • src/table/components/ListToolBar/index.tsx
  • src/table/TableToolbar.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
  • src/form/components/FormItem/FormItemRender/index.tsx
  • src/table/TableSearch.tsx
**/*index.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/AGENTS.md)

Export all public interface types for user convenience

Files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/form/components/Text/index.tsx
  • src/utils/useEditableArray/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/field/components/Select/index.tsx
  • src/field/components/Select/SearchSelect/index.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/card/components/CheckCard/index.tsx
  • src/form/components/FormItem/Group/index.tsx
  • src/table/components/ListToolBar/index.tsx
  • src/form/components/FormItem/FormItemRender/index.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/AGENTS.md)

All components must support dark mode

Files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/layout/components/GlobalHeader/ActionsContent.tsx
  • src/table/TableRender.tsx
  • src/form/components/Text/index.tsx
  • src/utils/useEditableArray/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/field/components/Select/index.tsx
  • src/card/components/CheckCard/Group.tsx
  • src/layout/ProLayout.tsx
  • src/field/components/Select/SearchSelect/index.tsx
  • src/table/useFetchData.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/card/components/CheckCard/index.tsx
  • src/table/Table.tsx
  • src/form/BaseForm/BaseForm.tsx
  • src/form/components/FormItem/Group/index.tsx
  • src/table/components/ListToolBar/index.tsx
  • src/table/TableToolbar.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
  • src/form/components/FormItem/FormItemRender/index.tsx
  • src/table/TableSearch.tsx
🧠 Learnings (25)
📓 Common learnings
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Use functional components and hooks, avoid class components
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/demo/**/*.tsx : Use functional components and hooks in demos
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Use `useLocale` hook from `components/locale/index.tsx` to get localization configuration from global context
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Support React 16 ~ 19 compatibility
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Props naming: Use `open` instead of `visible` for panel opening state

Applied to files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/form/components/Text/index.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Use functional components and hooks, avoid class components

Applied to files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/form/components/Text/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/card/components/CheckCard/Group.tsx
  • src/table/useFetchData.tsx
  • src/card/components/CheckCard/index.tsx
  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/demo/**/*.tsx : Use functional components and hooks in demos

Applied to files:

  • src/form/BaseForm/LightWrapper/index.tsx
  • src/form/components/Text/index.tsx
  • src/utils/useEditableArray/index.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/card/components/CheckCard/Group.tsx
  • src/layout/ProLayout.tsx
  • src/table/useFetchData.tsx
  • src/card/components/CheckCard/index.tsx
  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Components should display well at different screen sizes

Applied to files:

  • src/layout/components/GlobalHeader/ActionsContent.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/layout/components/PageHeader/index.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Support React 16 ~ 19 compatibility

Applied to files:

  • src/layout/components/GlobalHeader/ActionsContent.tsx
  • src/form/layouts/QueryFilter/index.tsx
  • src/field/components/Select/index.tsx
  • src/card/components/CheckCard/Group.tsx
  • src/table/useFetchData.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Props naming: Use `force` + `SubComponentName` + `Render` for sub-component forced rendering

Applied to files:

  • src/table/TableRender.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Props naming: Use `dataSource` for data sources

Applied to files:

  • src/table/TableRender.tsx
  • src/table/useFetchData.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Support theme customization through ConfigProvider

Applied to files:

  • src/table/TableRender.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Use `useLocale` hook from `components/locale/index.tsx` to get localization configuration from global context

Applied to files:

  • src/form/components/Text/index.tsx
  • src/field/components/Select/index.tsx
  • src/layout/ProLayout.tsx
  • src/card/components/CheckCard/index.tsx
  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Define specialized interfaces for component state, such as `ComponentNameState`

Applied to files:

  • src/form/components/Text/index.tsx
  • src/field/components/Select/index.tsx
  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Appropriately use React.memo, useMemo, and useCallback for performance optimization

Applied to files:

  • src/utils/useEditableArray/index.tsx
  • src/field/components/Select/index.tsx
  • src/layout/ProLayout.tsx
  • src/table/useFetchData.tsx
  • src/table/Table.tsx
  • src/form/BaseForm/BaseForm.tsx
  • src/table/TableToolbar.tsx
  • src/table/TableSearch.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Appropriately use React.memo, useMemo, and useCallback for performance

Applied to files:

  • src/utils/useEditableArray/index.tsx
  • src/field/components/Select/index.tsx
  • src/table/useFetchData.tsx
  • src/table/Table.tsx
  • src/form/BaseForm/BaseForm.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/demo/**/*.tsx : Use `useMemo`/`useCallback` appropriately for performance optimization in demos

Applied to files:

  • src/utils/useEditableArray/index.tsx
  • src/field/components/Select/index.tsx
  • src/table/useFetchData.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Use rc-motion for complex animations

Applied to files:

  • src/form/layouts/QueryFilter/index.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Use literal union types to define limited option sets

Applied to files:

  • src/field/components/Select/index.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Avoid using `enum`, prefer union types and `as const` instead

Applied to files:

  • src/field/components/Select/index.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*style*.{ts,tsx} : Use Ant Design's design token system in component styles

Applied to files:

  • src/card/components/CheckCard/Group.tsx
  • src/layout/components/PageHeader/index.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Component props should be defined using interface for extensibility

Applied to files:

  • src/field/components/Select/SearchSelect/index.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Component ref types should be explicitly defined using `React.ForwardRefRenderFunction`

Applied to files:

  • src/table/useFetchData.tsx
  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Props naming: Use `icon` for icons

Applied to files:

  • src/layout/components/PageHeader/index.tsx
  • src/layout/components/SiderMenu/BaseMenu.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Components should provide a `ref` attribute with structure including `nativeElement`, `focus`, and other functions

Applied to files:

  • src/table/Table.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{ts,tsx} : Appropriately use generics to enhance type flexibility

Applied to files:

  • src/form/components/FormItem/FormItemRender/index.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/demo/**/*.tsx : Demo import order: React → Dependencies → Component Library → Custom Components → Types → Styles

Applied to files:

  • src/table/TableSearch.tsx
📚 Learning: 2025-12-26T06:32:24.230Z
Learnt from: CR
Repo: ant-design/pro-components PR: 0
File: .cursor/rules/AGENTS.md:0-0
Timestamp: 2025-12-26T06:32:24.230Z
Learning: Applies to **/*.{tsx} : Use complete names rather than abbreviations in Antd naming

Applied to files:

  • src/table/TableSearch.tsx
🧬 Code graph analysis (2)
src/table/TableRender.tsx (1)
src/utils/useEditableArray/index.tsx (1)
  • recordKeyToString (44-47)
src/table/Table.tsx (1)
src/table/typing.ts (1)
  • FilterValue (79-79)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (40)
src/form/components/Text/index.tsx (2)

52-55: LGTM!

useMergedState 的使用方式正确,保持了受控/非受控状态的兼容性。初始值、value 和 onChange 的配置都符合预期。


1-1: 导入语句正确且兼容。@rc-component/util@1.7.0 正确导出 useMergedState,该钩子已在多个文件中成功使用(包括 src/utils/useEditableMap、src/utils/useEditableArray 和 src/table/useFetchData),无需进一步验证。

src/layout/components/PageHeader/index.tsx (1)

2-2: LGTM!

导入语句整理得当,将 ResizeObserver 的导入移至顶部统一管理,消除了重复导入。这是良好的代码组织实践。

src/layout/components/GlobalHeader/ActionsContent.tsx (1)

1-2: LGTM!

导入语句重组合理,与 PageHeader 的重构保持一致。将 ResizeObserver 导入统一到顶部,提升了代码可维护性。

src/card/components/CheckCard/index.tsx (2)

1-1: 导入语句更新正确

src/form/components/Text/index.tsx 中的更改一致,使用 @rc-component/utiluseMergedState 替代原有钩子。请参考前述文件的验证建议,确保库版本兼容性。


172-178: LGTM!

useMergedState 在 CheckCard 组件中的使用正确,支持受控(checked)和非受控(defaultChecked)两种模式。状态管理逻辑与原实现保持一致。

src/form/BaseForm/BaseForm.tsx (2)

1-8: LGTM!

useMergedState 已正确添加到 @rc-component/util 的导入列表中,与该文件现有的其他工具函数导入保持一致。


671-674: LGTM!

表单加载状态的 useMergedState 使用正确。默认值为 false,并通过 propsLoading 支持受控模式,onLoadingChange 回调配置合理,确保了提交按钮加载状态的正确管理。

src/form/BaseForm/LightWrapper/index.tsx (2)

4-4: 导入变更正确。

正确添加了 useState 到 React 导入列表中,以支持下方的状态管理变更。


74-74: 状态管理简化合理。

open 状态从 useMountMergeState 迁移到标准的 useState(false) 是合适的。该状态为纯本地 UI 状态,用于控制下拉框的显示/隐藏,不需要受控/非受控模式的支持,使用 useState 更简洁明了。

src/table/TableRender.tsx (4)

13-13: 导入清理正确。

移除了未使用的 Key 类型导入,保持代码整洁。


18-18: 导入格式调整。

将多行类型导入合并为单行,格式更简洁。这是纯格式化变更,无功能影响。


63-66: 格式化调整。

recordKeyToString 调用进行了换行格式调整,提高可读性。功能保持不变。


260-262: 条件表达式格式化。

notNeedCardDom 条件判断拆分为多行,提高代码可读性。逻辑保持不变。

src/form/layouts/QueryFilter/index.tsx (4)

1-2: 依赖导入正确。

正确添加了 RcResizeObserveruseMergedState 的导入,以支持组件的状态管理重构。


8-8: React hooks 导入更新。

添加了 useState 到 React 导入列表中,用于下方的 width 状态管理。


10-10: 工具函数导入调整。

移除了 useMountMergeState 导入,保留了 isBrowser 工具函数的导入。符合本次重构的目标。


532-534: width 状态管理简化合理。

width 状态从 useMountMergeState 迁移到 useState 是正确的。该状态为组件内部响应式布局计算使用的纯本地状态,通过 RcResizeObserver 的回调更新(line 580),不需要受控/非受控模式支持。初始值逻辑保持不变。

src/layout/components/SiderMenu/BaseMenu.tsx (5)

2-2: 正确引入新的状态管理 hook。

添加了 useMergedState@rc-component/util 的导入,用于替代项目本地的 useMountMergeState


10-10: 工具导入清理。

移除了 useMountMergeState 导入,保留了 isImgisUrl 工具函数。符合迁移目标。


575-575: 本地状态简化正确。

defaultOpenAll 是纯内部状态,用于跟踪菜单默认展开行为,使用 useState 替代 useMountMergeState 是合适的简化。


577-591: openKeys 受控/非受控模式处理正确。

使用 useMergedState 管理 openKeys 状态是正确的,因为它需要支持受控和非受控模式:

  • 初始值逻辑正确处理了 menu?.defaultOpenAllpropsOpenKeys === false 的情况
  • value 选项正确地将 propsOpenKeys === false 转换为 undefined 以支持非受控模式
  • onChange 正确绑定到 onOpenChange 回调

这种实现保持了组件的灵活性和向后兼容性。


593-605: selectedKeys 受控/非受控模式处理正确。

使用 useMergedState 管理 selectedKeys 状态是合适的:

  • 初始值设为空数组 []
  • 正确绑定 propsSelectedKeys 作为受控值
  • onChange 回调正确包装了 onSelect,仅在 onSelect 存在时才调用

这种实现既支持受控模式(通过 selectedKeys prop),也支持非受控模式,并保持了 API 的向后兼容性。

src/field/components/Select/SearchSelect/index.tsx (1)

31-34: 接口声明格式化调整。

SearchSelectProps 接口的 extends 子句从单行拆分为多行格式,提高代码可读性。这是纯格式化变更,接口定义的语义和功能保持完全不变。

src/layout/ProLayout.tsx (1)

1-1: LGTM! 状态管理钩子迁移正确。

useMountMergeState 迁移到 useMergedState 的改动正确,两个钩子的 API 兼容,状态管理逻辑保持不变。menuLoading 状态通过 menu?.loading 进行受控,通过 menu?.onLoadingChange 处理变更回调。

Also applies to: 19-19, 447-450

src/form/components/FormItem/FormItemRender/index.tsx (1)

57-58: LGTM! 类型参数格式调整。

这是一个纯格式化改动,将较长的泛型约束拆分为两行以提高可读性。类型定义本身没有变化,不影响运行时行为。

src/field/components/Select/index.tsx (1)

1-1: LGTM! 状态管理钩子迁移符合预期。

useMountMergeState 迁移到 useControlledState 的改动正确。新的 API 使用初始值工厂函数和受控值参数,符合受控/非受控模式。defaultOptions 作为受控值传入,初始值根据 props.valueEnum 动态计算。逻辑行为保持一致。

Also applies to: 271-274

src/table/components/ListToolBar/index.tsx (1)

1-1: LGTM! 导入语句整理。

ResizeObserver 的导入移至文件顶部,整合重复的导入声明。这是良好的代码组织实践,没有功能变更。

src/table/TableSearch.tsx (1)

4-4: LGTM! 导入顺序调整。

类型导入的顺序调整,没有运行时行为变更。这是代码组织层面的优化。

src/utils/useEditableArray/index.tsx (2)

399-399: LGTM - 简化布尔状态的正确做法

将简单的布尔型 loading 状态从 useMountMergeState 迁移到 useState 是合理的简化。对于不需要受控/合并逻辑的简单标志位,useState 更加直接和高效。


517-517: LGTM - 与 SaveEditableAction 保持一致

与 Line 399 的变更保持一致,将 loading 状态简化为 useState

src/card/components/CheckCard/Group.tsx (1)

320-325: LGTM - 标准的 useMergedState 迁移

useMountMergeStateuseMergedState 的迁移正确,配置项(valueonChange)都已妥善处理,保持了受控/非受控模式的兼容性。

src/table/Table.tsx (3)

233-240: LGTM - useControlledState 迁移正确

selectedRowKeys 使用 useControlledState 进行受控/非受控状态管理是正确的。配合 Line 562-567 的 onChange 手动处理,逻辑完整。


242-251: LGTM - 惰性初始化逻辑清晰

formSearch 使用 useState 配合初始化函数,正确处理了手动请求模式和搜索禁用的场景。


278-281: 州筛选/排序状态的动态列行为是设计的,不存在缺陷

proFilterproSort 使用 useState 初始化,在 propsColumns 变化时不会自动更新。这是有意的设计

  • 当列动态变更时,保留用户已设置的筛选/排序状态
  • 针对已删除列的孤立筛选值通过 parseProFilteredValue 安全处理(返回 undefined)
  • 用户可通过 resetAll() 显式重置筛选/排序状态

无需添加 useEffect 来同步新的默认值。

src/form/components/FormItem/Group/index.tsx (1)

36-42: LGTM - 折叠状态的标准迁移

collapsed 状态正确迁移到 useMergedState,使用初始化函数提供默认值,并通过 props.collapsedprops.onCollapse 支持受控模式。

src/table/useFetchData.tsx (4)

1-2: LGTM!导入更新正确支持状态钩子迁移。

导入语句已正确更新以支持从 useMountMergeStateuseMergedStateuseState 的迁移。


94-100: 状态迁移一致且正确。

tableLoading 的状态迁移与 tableDataList 保持一致,正确保留了复杂的 value 计算逻辑(处理 object/boolean 类型的 loading)。


131-131: 正确简化为 useState。

pollingLoading 是纯内部状态,不需要外部控制或回调,使用 useState 替代 useMountMergeState 是恰当的简化,符合"选择最简单适用的钩子"原则。


84-89: useMergedState API 兼容性验证完成。

代码变更正确无误。根据 @rc-component/util@1.7.0 官方 API 文档确认:

  • useMergedState 的 API 签名与代码使用完全兼容
  • 初始值处理:defaultData 作为 defaultStateValue 参数正确传递
  • 受控/非受控行为:valueonChange 选项遵循标准 RC 组件库模式,行为与原 useMountMergeState 一致
  • React 16-19 兼容性:@rc-component/util 原生支持 React 16-19

此次状态管理迁移无需进一步调整。

@chenshuai2144 chenshuai2144 merged commit eb7aa3a into ant-design:master Jan 14, 2026
6 of 9 checks passed
@zzjiaxiang zzjiaxiang deleted the remove-old-api branch January 14, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧱 antd size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants