fix(cascader): onPathChange is not a function#2308
Conversation
Walkthrough本次修改涉及在 Changes
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Additional context usedBiome
Additional comments not posted (4)
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #2308 +/- ##
==========================================
+ Coverage 85.84% 85.87% +0.02%
==========================================
Files 217 217
Lines 22811 22811
Branches 2490 2494 +4
==========================================
+ Hits 19583 19589 +6
+ Misses 3223 3217 -6
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 0
Outside diff range and nitpick comments (2)
src/packages/cascader/cascader.tsx (1)
Line range hint
62-62: 在多个位置使用了any类型,这可能会导致类型安全问题。建议为这些变量提供更具体的类型,以利于静态类型检查和后续的代码维护。- const [state] = useState({ - optionsData: [] as any, - panes: [ - { - nodes: [] as any, - selectedNode: [] as CascaderOption | null, - paneKey: '', - }, - ], - tree: new Tree([], {}), - tabsCursor: 0, // 选中的tab项 - initLoading: false, - currentProcessNode: [] as CascaderOption | null, - configs: { - lazy, - onLoad, - optionKey, - format, - }, - lazyLoadMap: new Map(), - }) + const [state] = useState<{ + optionsData: CascaderOption[], + panes: CascaderPane[], + tree: Tree, + tabsCursor: number, + initLoading: boolean, + currentProcessNode: CascaderOption | null, + configs: { + lazy: boolean, + onLoad: (node: CascaderOption, resolve: (nodes: CascaderOption[]) => void) => void, + optionKey: CascaderOptionKey, + format: CascaderFormat, + }, + lazyLoadMap: Map<CascaderOption, Promise<CascaderOption[]>>, + }>({ + optionsData: [], + panes: [], + tree: new Tree([], {}), + tabsCursor: 0, + initLoading: false, + currentProcessNode: null, + configs: { + lazy, + onLoad, + optionKey, + format, + }, + lazyLoadMap: new Map(), + })Also applies to: 63-63, 64-64, 144-144, 147-147, 229-229, 242-242, 244-244, 333-334, 365-365, 379-379
src/packages/cascader/cascader.taro.tsx (1)
Line range hint
63-63: 在多个位置使用了any类型,这可能会导致类型安全问题。建议为这些变量提供更具体的类型,以利于静态类型检查和后续的代码维护。- const [state] = useState({ - optionsData: [] as any, - panes: [ - { - nodes: [] as any, - selectedNode: [] as CascaderOption | null, - paneKey: '', - }, - ], - tree: new Tree([], {}), - tabsCursor: 0, // 选中的tab项 - initLoading: false, - currentProcessNode: [] as CascaderOption | null, - configs: { - lazy, - onLoad, - optionKey, - format, - }, - lazyLoadMap: new Map(), - }) + const [state] = useState<{ + optionsData: CascaderOption[], + panes: CascaderPane[], + tree: Tree, + tabsCursor: number, + initLoading: boolean, + currentProcessNode: CascaderOption | null, + configs: { + lazy: boolean, + onLoad: (node: CascaderOption, resolve: (nodes: CascaderOption[]) => void) => void, + optionKey: CascaderOptionKey, + format: CascaderFormat, + }, + lazyLoadMap: Map<CascaderOption, Promise<CascaderOption[]>>, + }>({ + optionsData: [], + panes: [], + tree: new Tree([], {}), + tabsCursor: 0, + initLoading: false, + currentProcessNode: null, + configs: { + lazy, + onLoad, + optionKey, + format, + }, + lazyLoadMap: new Map(), + })Also applies to: 64-64, 145-145, 148-148, 230-230, 243-243, 245-245, 334-335, 366-366, 380-380
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
InternalCascader组件中的onPathChange函数调用,使用可选链操作符 (?.) 来处理onPathChange可能未定义的情况,防止调用未定义函数时出现错误。