-
Notifications
You must be signed in to change notification settings - Fork 59
refactor: Upgrade utils and replace useMergedState #299
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
Merged
zombieJ
merged 9 commits into
react-component:master
from
EmilyyyLiu:useControlledState-use
Sep 19, 2025
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3fcc802
refactor: Upgrade utils and replace useMergedState
536a1a7
chore: debug of ci
zombieJ fe943cb
chore: adjust ci
zombieJ 95f1f1a
chore: rollback
zombieJ f80ca06
chore: use utoo
zombieJ 3eb7205
chore: use back
zombieJ d827c50
chore: rollback
zombieJ 364cf47
test: fix test
zombieJ 985512f
test: fix test
zombieJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
将
useMergedState
替换为useControlledState
的重构是正确的。然而,这里有一个潜在的先前就存在的问题。当
InternalMentions
在Mentions
组件内部使用时,此处的value
prop 始终是undefined
。这意味着InternalMentions
实际上总是在非受控模式下运行,其内部的mergedValue
状态与Mentions
组件的mergedValue
状态是分离的。这会导致一个 bug:当
Mentions
组件作为受控组件并且其value
prop 从外部更新时,TextArea
中显示的值不会更新。为了修复这个问题,
Mentions
组件需要将其mergedValue
传递给InternalMentions
的value
prop。虽然修复超出了本次变更的范围,但由于你正在处理状态管理逻辑,这可能是一个值得考虑解决的问题。一个可能的修复方案是在
Mentions
组件中: