-
Notifications
You must be signed in to change notification settings - Fork 194
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
type: correct type annotation for treeTitleRender #595
Conversation
…mentation for treeTitleRender prop
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次变更主要涉及对 Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
src/TreeSelect.tsx (1)
Line range hint
292-294
: 建议修复 labelInValue 条件下的渲染逻辑在 labelInValue 为 true 时,当前实现可能会导致标签渲染不一致。建议修改为:
- const label = labelInValue ? targetItem?.label : treeTitleRender?.(targetItem); + const label = treeTitleRender?.(targetItem) ?? (labelInValue ? targetItem?.label : undefined);这样可以确保
treeTitleRender
的优先级始终一致,无论labelInValue
的值如何。README.md (1)
97-97
: 建议修正以下语法问题:
treeData
属性描述中的语法问题key
属性描述中的所有格使用问题建议按如下方式修改:
-| treeData | treeNodes data Array, if set it then you need not to construct children TreeNode. (value should be unique across the whole array) | array<{value,label,children, [disabled,selectable]}> | [] | +| treeData | treeNodes data Array, if set, you don't need to construct children TreeNode. (value should be unique across the whole array) | array<{value,label,children, [disabled,selectable]}> | [] | -| key | it's value must be unique across the tree's all TreeNode, you must set it | String | - | +| key | its value must be unique across the tree's all TreeNode, you must set it | String | - |Also applies to: 116-116
🧰 Tools
🪛 LanguageTool
[typographical] ~97-~97: Consider adding a comma.
Context: ... | treeNodes data Array, if set it then you need not to construct children Tree...(IF_THEN_COMMA)
[grammar] ~97-~97: Did you mean “construct”?
Context: ...data Array, if set it then you need not to construct children TreeNode. (value should be uni...(NEEDNT_TO_DO_AND_DONT_NEED_DO)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
README.md
(1 hunks)src/TreeSelect.tsx
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[typographical] ~97-~97: Consider adding a comma.
Context: ... | treeNodes data Array, if set it then you need not to construct children Tree...
(IF_THEN_COMMA)
[grammar] ~97-~97: Did you mean “construct”?
Context: ...data Array, if set it then you need not to construct children TreeNode. (value should be uni...
(NEEDNT_TO_DO_AND_DONT_NEED_DO)
[uncategorized] ~101-~101: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...t.body;} | | autoClearSearchValue | auto clear search input value when multiple select...
(AUTO_HYPHEN)
[grammar] ~116-~116: Did you mean to use the possessive pronoun “its”?
Context: ...bool | false | | key | it's value must be unique across the tree's ...
(IT_S_ITS)
🔇 Additional comments (3)
src/TreeSelect.tsx (1)
96-96
: 类型定义修改正确!
将 treeTitleRender
的参数类型从 ValueType
更改为 OptionType
是合适的,因为这样可以访问到完整的节点数据,提供了更好的类型安全性。
README.md (2)
107-107
: 文档更新符合预期!
treeTitleRender
属性的类型注释和文档说明清晰准确,与 PR 目标保持一致。
122-126
: 建议验证性能优化建议的时效性
当前文档中的性能优化建议针对大数据量场景(超过5000个节点)。建议验证这些建议在当前版本中是否仍然适用。
✅ Verification successful
The previous command failed because the --type=test
flag wasn't supported. Let's try a broader search to find performance-related content and TreeSelect implementation details to verify the optimization recommendations.
Let's examine the actual implementation to verify if these performance recommendations are still valid and possibly find any additional context about performance optimizations.
性能优化建议仍然适用且有代码支持
代码分析显示当前的性能优化建议是合理且有效的:
- 组件实现中使用了
useCache
hook 来优化大数据量场景的性能 - TreeSelect 组件支持虚拟滚动(virtual scrolling)来处理大量节点
- 提供了
treeCheckStrictly
模式作为treeCheckable
的性能优化选项
建议保留这些优化提示,因为它们:
- 有助于用户在处理大数据量时避免性能问题
- 与组件的实际实现保持一致
- 提供了切实可行的优化方案
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 搜索相关的性能测试用例和基准测试
rg -l "performance|benchmark" --type=test
Length of output: 72
Script:
#!/bin/bash
# Search for performance related tests and benchmarks in all files
rg -l "performance|benchmark"
# Search for TreeSelect component implementation and tests
fd -e ts -e tsx -e js -e jsx TreeSelect
# Look for any performance related comments or documentation
rg -i "performance|优化|性能" --type md
Length of output: 177
Script:
#!/bin/bash
# Check TreeSelect implementation for performance related code and comments
cat src/TreeSelect.tsx
# Check useCache hook implementation as it might be related to performance
cat src/hooks/useCache.ts
# Look for any performance related tests
rg -C 5 "performance|benchmark" src/
Length of output: 23001
README.md
Outdated
| removeIcon | specify the remove icon | ReactNode \| (props: TreeProps) => ReactNode | - | | ||
| switcherIcon | specify the switcher icon | ReactNode \| (props: TreeProps) => ReactNode | - | | ||
| virtual | Disable virtual when `false` | false | - | | ||
| treeTitleRender | Custom render nodes | (nodeData: OptionType) => ReactNode | - | |
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.
别改 markdown 格式,这样 diff 没法看。
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.
ok
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.
佬 这块husky好像会格式化md的文件
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #595 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 520 520
Branches 151 153 +2
=========================================
Hits 520 520 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
README.md (3)
57-107
: 表格格式和属性描述需要改进建议对以下几点进行修改:
- 在
showCheckedStrategy
属性的描述中,"Default just show child" 的语法不正确,建议修改为 "Default only shows child nodes"。- 在
treeData
属性描述中,建议在 "if set it" 后添加逗号,提高可读性。autoClearSearchValue
属性描述建议添加连字符,改为 "auto-clear"。🧰 Tools
🪛 LanguageTool
[uncategorized] ~85-~85: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...ust show parent treeNode). Default just show child. | enum{TreeSelect.SHOW_ALL, Tree...(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
[typographical] ~97-~97: Consider adding a comma.
Context: ... | treeNodes data Array, if set it then you need not to construct children Tree...(IF_THEN_COMMA)
[grammar] ~97-~97: Did you mean “construct”?
Context: ...data Array, if set it then you need not to construct children TreeNode. (value should be uni...(NEEDNT_TO_DO_AND_DONT_NEED_DO)
[uncategorized] ~102-~102: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...t.body;} | | autoClearSearchValue | auto clear search input value when multiple select...(AUTO_HYPHEN)
111-119
: TreeNode 属性表格中的语法错误在
key
属性的描述中,"it's value" 应该修改为 "its value",因为这里需要使用所有格形式。🧰 Tools
🪛 LanguageTool
[grammar] ~116-~116: Did you mean to use the possessive pronoun “its”?
Context: ...bool | false | | key | it's value must be unique across the tree's ...(IT_S_ITS)
122-126
: 优化建议部分的表述需要改进在第二条优化建议中,"in a page" 应改为 "on a page",这样更符合英语习惯用语。
另外,建议为优化建议添加更详细的解释,帮助用户理解为什么要遵循这些建议。例如,可以解释大量展开节点或使用多个 TreeSelect 组件可能导致的性能问题。
🧰 Tools
🪛 LanguageTool
[uncategorized] ~125-~125: The preposition “on” seems more likely in this position than the preposition “in”.
Context: ... not exist manyTreeSelect
components in a page at the same time. - Recommend...(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_IN_ON)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
README.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[uncategorized] ~85-~85: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...ust show parent treeNode). Default just show child. | enum{TreeSelect.SHOW_ALL, Tree...
(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
[typographical] ~97-~97: Consider adding a comma.
Context: ... | treeNodes data Array, if set it then you need not to construct children Tree...
(IF_THEN_COMMA)
[grammar] ~97-~97: Did you mean “construct”?
Context: ...data Array, if set it then you need not to construct children TreeNode. (value should be uni...
(NEEDNT_TO_DO_AND_DONT_NEED_DO)
[uncategorized] ~102-~102: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...t.body;} | | autoClearSearchValue | auto clear search input value when multiple select...
(AUTO_HYPHEN)
[grammar] ~116-~116: Did you mean to use the possessive pronoun “its”?
Context: ...bool | false | | key | it's value must be unique across the tree's ...
(IT_S_ITS)
[uncategorized] ~125-~125: The preposition “on” seems more likely in this position than the preposition “in”.
Context: ... not exist many TreeSelect
components in a page at the same time. - Recommend...
(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_IN_ON)
🔇 Additional comments (1)
README.md (1)
99-99
: 新增的 treeTitleRender 属性文档完善
treeTitleRender
属性的类型定义和描述清晰准确,与代码实现保持一致。
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
README.md (1)
100-100
: 需要完善 treeTitleRender 属性的文档建议按照文档格式规范补充以下内容:
- 添加默认值列(使用
-
表示)- 扩展描述信息,说明该属性的具体用途和使用场景
-|treeTitleRender | Custom render nodes | (nodeData: OptionType) => ReactNode | +|treeTitleRender | 自定义节点渲染函数,用于自定义树节点的展示内容 | (nodeData: OptionType) => ReactNode | - |🧰 Tools
🪛 Markdownlint
100-100: Expected: 4; Actual: 3; Too few cells, row will be missing data
Table column count(MD056, table-column-count)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
README.md
(2 hunks)
🧰 Additional context used
🪛 Markdownlint
README.md
100-100: Expected: 4; Actual: 3; Too few cells, row will be missing data
Table column count
(MD056, table-column-count)
🔇 Additional comments (1)
README.md (1)
140-140
: 许可证声明看起来没问题
MIT 许可证的声明清晰明确。
中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
ant-design/ant-design#51484
💡 Background and Solution
📝 Change Log
Summary by CodeRabbit
新功能
TreeSelect
组件中添加了treeTitleRender
属性,允许自定义节点渲染。文档
README.md
文件,增强了TreeSelect
属性的可读性,特别是对treeTitleRender
属性的描述。