-
Notifications
You must be signed in to change notification settings - Fork 284
fix(swiper): duration属性透传 #3337
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
fix(swiper): duration属性透传 #3337
Conversation
Walkthrough移除了对 Swiper 组件 props 中 duration 的解构提取,使该属性不再被单独拿出并通过剩余 props 转发给内部的 TaroSwiper;其他事件和导出签名保持不变。(≤50 字) Changes
Sequence Diagram(s)sequenceDiagram
participant Consumer as 使用者组件
participant Swiper as Swiper (Taro)
participant TaroSwiper as TaroSwiper
Consumer->>Swiper: <Swiper duration=... otherProps />
Swiper->>TaroSwiper: render({...otherProps, duration})
Note right of TaroSwiper: 接收并使用传入的 duration(若有)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ 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. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat_v3.x #3337 +/- ##
==========================================
Coverage 88.13% 88.13%
==========================================
Files 291 291
Lines 19140 19140
Branches 2971 2971
==========================================
Hits 16869 16869
Misses 2266 2266
Partials 5 5 ☔ 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: 1
🧹 Nitpick comments (4)
src/packages/swiper/swiper.taro.tsx (4)
66-68
: 同步 current 时避免||
带来的 0 值误判
setInnerValue(current || defaultValue)
在current === 0
时会误用defaultValue
。建议改为 nullish 合并。- setInnerValue(current || defaultValue) + setInnerValue(current ?? defaultValue)
58-64
: 简化 childrenCount:直接使用 React.Children.count当前用
map
计数偏冗长,且更易出错。用Children.count
更直接。- const childrenCount = useMemo(() => { - let c = 0 - React.Children.map(children, (child, index) => { - c += 1 - }) - return c - }, [children]) + const childrenCount = useMemo(() => Children.count(children), [children])
98-120
: childrenCount 为 0 时 next/prev 存在取模 0 风险当没有子项时,
% childrenCount
可能产生NaN
。建议在next/prev
内做早返回保护。next: () => { + if (childrenCount === 0) return if (loop) { setInnerValue((innerValue + 1) % childrenCount) } else { setInnerValue( innerValue + 1 >= childrenCount ? innerValue : innerValue + 1 ) } }, prev: () => { + if (childrenCount === 0) return if (loop) { let next = innerValue - 1 next = next < 0 ? childrenCount + next : next setInnerValue(next % childrenCount) } else { setInnerValue(innerValue - 1 <= 0 ? 0 : innerValue - 1) } },
140-141
: 确认 circular 的 API 期望;必要时允许 circular 显式覆盖 loop当前传递的是
circular={loop}
,而上方也解构了circular
。若希望外部可直接用circular
覆盖,建议使用 nullish 合并;若不支持circular
,则建议移除解构,避免误导。- circular={loop} + circular={circular ?? loop}请确认组件对外 API 期望是仅支持
loop
还是同时兼容circular
。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/packages/swiper/swiper.taro.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test
- GitHub Check: test
- GitHub Check: build
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.
duration为0会变成500啊
那很是我考虑不周了😱😱😱 |
别的地方也没有用到duration,直接把解构去掉就好啦 |
好滴好滴 |
@Miles-hxy 改好了,打包试了一下没毛病 |
* chore(release): v3.0.18 * fix(swiper): duration属性透传 (#3337) * feat: 修复属性透传 * feat: 直接删除duration * fix(range): taro环境异步渲染useReady不会触发 (#3297) * fix(range): taro环境异步渲染useReady不会触发 * refactor: 将组件中使用的useReady替换为useLayoutEffect * chore: 升级版本号 * feat(popup): 增加上下滑动修改高度 * fix(input): 兼容h5和小程序获取原生input标签 (#3341) * feat: inputRef获取真实input-dom * feat: 兼容小程序和h5获取input标签 * feat: 取消?问好,出错直接抛出 * feat(Popup): 新增弹层可上下滑动 (#3340) * feat: 支持popup 高度可以伸缩 * feat: 适配小程序 * feat: 修改文档 * fix: 默认值不需要,走样式 * feat: 增加使用的限制条件 * docs: 增加文档 * fix: 适配鸿蒙,初始值重置修改 * test: 添加单测 * fix: 增加h5 的初始值 * fix: 增加高度下限约束 * test: fix 单测 * feat(popup): 添加自定义顶部 * fix(input): taro 下只读可以点击 --------- Co-authored-by: Alex.hxy <[email protected]> Co-authored-by: YONGQI <[email protected]> Co-authored-by: RyanCW <[email protected]>
🤔 这个变动的性质是?
🔗 相关 Issue
#3336
💡 需求背景和解决方案
在属性解构的时候把duration单独解构出来,但是最终给TaroSwiper赋值的时候没有传递进去。
☑️ 请求合并前的自查清单
Summary by CodeRabbit