-
Notifications
You must be signed in to change notification settings - Fork 50
refactor: Upgrade utils and replace useMergedState #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Upgrade utils and replace useMergedState #136
Conversation
Walkthrough此次变更包含:在 package.json 中将依赖 @rc-component/util 从 ^1.2.0 升至 ^1.3.0;在 src/Input.tsx 中将受控/非受控值管理从 useMergedState 切换为 useControlledState,并相应调整初始化参数与导入路径。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant P as Props
participant I as Input(Component)
participant H as useControlledState
Note over I,H: 初始化
P->>I: defaultValue, value
I->>H: useControlledState(defaultValue, value)
H-->>I: [value, setValue]
Note over I,U: 交互与受控切换
U->>I: 输入变更(onChange)
alt 受控(value !== undefined)
I->>P: 触发 onChange(新值)
I-->>U: 显示来自 props.value
else 非受控(value === undefined)
I->>H: setValue(新值)
I-->>U: 显示内部状态值
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🔇 Additional comments (3)
✨ Finishing Touches
🧪 Generate unit tests
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @EmilyyyLiu, 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!
This pull request refactors the Input component by updating a core utility dependency and migrating its internal state management from useMergedState to useControlledState. This change aligns the component with a more explicit pattern for handling controlled and uncontrolled states, enhancing clarity and maintainability.
Highlights
- Dependency Upgrade: The
@rc-component/utilpackage has been upgraded from version^1.2.0to^1.3.0. - State Hook Replacement: The
useMergedStatehook insrc/Input.tsxhas been replaced withuseControlledStatefor managing the component's value.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
你好,感谢你的贡献。本次 PR 将 @rc-component/util 依赖从 ^1.2.0 升级到了 ^1.3.0,并使用新的 useControlledState hook 替换了 useMergedState 来管理输入框的值。这是一个很好的重构,使得状态管理逻辑更加清晰和简洁。代码改动正确,符合预期,提升了代码的可读性和可维护性。做得很好!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #136 +/- ##
=======================================
Coverage 97.70% 97.70%
=======================================
Files 4 4
Lines 218 218
Branches 82 82
=======================================
Hits 213 213
Misses 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
关联issue:ant-design/ant-design#54854
替换 useMergedState 为 useControlledState
Summary by CodeRabbit