Skip to content

refactor(useMergedState): use hasValue for merged value check - #510

Merged
li-jia-nan merged 2 commits into
react-component:masterfrom
hasnum-stack:master
Oct 31, 2026
Merged

li-jia-nan merged 2 commits into
react-component:masterfrom
hasnum-stack:master

Conversation

@hasnum-stack

@hasnum-stack hasnum-stack commented Mar 19, 2024 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • 重构
    • 将合并值判断从三元表达式替换为统一的存在性检查方法,逻辑更清晰,代码更一致,维护成本更低。
    • 通过一致的判断方式减少潜在边界分支,提升稳定性与可读性。
    • 不影响任何功能、界面或交互;对现有使用场景完全兼容,用户无感知变更。

@vercel

vercel Bot commented Mar 19, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
util Ready Ready Preview Comment Sep 30, 2025 1:14am

@coderabbitai

coderabbitai Bot commented Sep 30, 2025 •

Copy link
Copy Markdown

Walkthrough

在 src/hooks/useMergedState.ts 中,把合并值的判定从 value !== undefined ? value : innerValue 改为 hasValue(value) ? value : innerValue。其余关于 value、innerValue 与 postState 的逻辑保持不变,未修改导出或公共声明。

Changes

Cohort / File(s) Summary
合并状态判定逻辑调整
src/hooks/useMergedState.ts
将三元判定从 value !== undefined ? value : innerValue 替换为 hasValue(value) ? value : innerValue;其余逻辑未变,更改不影响导出接口。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Pre-merge checks: Passed 2
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确描述了主要变更:在 useMergedState 中使用 hasValue 判断 mergedValue。标题简洁、明确,并与代码变更一致。
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

我在代码田里轻轻跳,
hasValue 点点头,undefined被识别到;
三元换新装,语义更明了,
内外值相依靠,状态不动摇。
咔哒一笔,小兔挥爪:合并,收好!

@li-jia-nan li-jia-nan changed the title chore(useMergedState): mergedValue值的判断改成统一的hasValue refactor(useMergedState): use hasValue for merged value check Oct 31, 2026
@li-jia-nan
li-jia-nan merged commit 78d258b into react-component:master Oct 31, 2026

This branch was successfully deployed

1 active deployment
Preview — 39f5f000 Deployed Sep 30, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants