-
-
Notifications
You must be signed in to change notification settings - Fork 98
update destroyOnClose to destroyOnHidden #481
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更改主要将 Drawer 组件及其相关用例中的 destroyOnClose 属性统一重命名为 destroyOnHidden,并同步调整了相关类型定义、测试代码和示例文档。同时,对部分组件声明方式进行了类型增强和代码风格优化,新增了 @types/node 开发依赖。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Drawer
participant DrawerPanel
participant DrawerPopup
User->>Drawer: 设置 destroyOnHidden 属性
Drawer->>DrawerPopup: 渲染 DrawerPopup
DrawerPopup->>DrawerPanel: 渲染 DrawerPanel
Drawer-->>User: 根据 destroyOnHidden 控制内容销毁时机
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
docs/examples/forceRender.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /.eslintrc.js
src/DrawerPanel.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /.eslintrc.js
src/Drawer.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /.eslintrc.js
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #481 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 146 145 -1
Branches 54 54
=========================================
- Hits 146 145 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
🧹 Nitpick comments (3)
src/Drawer.tsx (2)
98-98
: 使用箭头函数简化 Context 创建使用更简洁的箭头函数语法重构 refContext 创建逻辑,提高代码可读性。
113-113
: 改进代码格式在 eventHandlers 对象和 drawerPopupProps 声明之间添加空行,提高代码可读性。
docs/examples/forceRender.tsx (1)
52-52
: 按钮文本需要更新按钮文本仍然显示为 "Destroy On Close",建议更新为 "Destroy On Hidden" 以保持与新属性名称的一致性。
- <Button onClick={() => setOpen2(true)}>Destroy On Close</Button> + <Button onClick={() => setOpen2(true)}>Destroy On Hidden</Button>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/examples/forceRender.tsx
(1 hunks)package.json
(1 hunks)src/Drawer.tsx
(4 hunks)src/DrawerPanel.tsx
(1 hunks)src/DrawerPopup.tsx
(2 hunks)tests/index.spec.tsx
(1 hunks)
🔇 Additional comments (11)
package.json (1)
59-59
: 添加 Node.js 类型定义包添加
@types/node
开发依赖以支持 Node.js 的 TypeScript 类型定义,有助于提升代码开发体验和类型安全性。src/DrawerPanel.tsx (1)
36-36
: 组件类型定义优化将普通函数组件重构为使用
React.FC<Readonly<DrawerPanelProps>>
的形式,增强了类型安全性并确保了 props 的不可变性。这种写法更符合现代 React 开发规范。src/DrawerPopup.tsx (2)
80-83
: 重构组件为 ForwardRefRenderFunction将 DrawerPopup 组件重构为使用
React.ForwardRefRenderFunction
的箭头函数形式,提高了类型安全性和代码一致性。这种方式更明确地表达了组件的 ref 转发意图。
381-381
: 函数结尾符号更新箭头函数语法变更导致的结尾符号从大括号变为分号加大括号,与上述组件定义方式变更相对应。
src/Drawer.tsx (3)
24-24
: 属性名称重命名:destroyOnClose → destroyOnHidden将
destroyOnClose
属性重命名为destroyOnHidden
,名称更准确地反映了组件的实际行为 - 在抽屉隐藏时销毁组件,而不仅仅是关闭时。
44-44
: 解构赋值中的属性名称更新与接口定义保持一致,更新了属性解构中的名称为
destroyOnHidden
。
101-101
: 条件判断中使用更新后的属性名在条件渲染逻辑中将
destroyOnClose
更新为destroyOnHidden
,确保功能与之前保持一致。docs/examples/forceRender.tsx (1)
35-35
: 属性名称已正确更新已将
destroyOnClose
属性更新为destroyOnHidden
,符合组件 API 的更新。tests/index.spec.tsx (3)
186-186
: 测试描述块名称已正确更新描述块名称已从
destroyOnClose
更新为destroyOnHidden
,与组件 API 的变更保持一致。
188-190
: 测试案例中的属性名已正确更新测试案例中的
destroyOnClose
属性已更新为destroyOnHidden
,保持了与组件 API 变更的一致性。
196-200
: 内联渲染测试中的属性名已正确更新使用
getContainer={false}
的内联渲染测试中,destroyOnClose
属性已正确更新为destroyOnHidden
。
rc的不需要做废弃直接改吗? |
不需要,废弃逻辑在 antd 侧 |
Summary by CodeRabbit
新功能
destroyOnClose
更名为destroyOnHidden
,以更准确地反映内容销毁的时机。文档
样式
测试
杂项
@types/node
。