-
Notifications
You must be signed in to change notification settings - Fork 298
fix(pagination): color of icon #2769
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||
| import React, { ReactElement, ReactNode } from 'react' | ||||||||||||||
| import { harmony } from './platform-taro' | ||||||||||||||
|
|
||||||||||||||
| interface ColorProps { | ||||||||||||||
| color?: string | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * 为支持 Harmony 的 React 元素添加颜色属性 | ||||||||||||||
| * @param maybeElement - 要处理的 React 节点 | ||||||||||||||
| * @param color - 要添加的颜色值(如:'#ff0000') | ||||||||||||||
| * @returns 处理后的 React 节点 | ||||||||||||||
| */ | ||||||||||||||
| function addColorForHarmony(maybeElement: ReactNode, color: string) { | ||||||||||||||
| if (React.isValidElement(maybeElement) && harmony()) { | ||||||||||||||
| return React.cloneElement<ColorProps>(maybeElement as ReactElement, { | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议添加类型安全检查 直接将 建议修改如下: - return React.cloneElement<ColorProps>(maybeElement as ReactElement, {
+ const element = maybeElement as ReactElement
+ if (!React.isValidElement(element)) {
+ return maybeElement
+ }
+ return React.cloneElement<ColorProps>(element, {📝 Committable suggestion
Suggested change
|
||||||||||||||
| color, | ||||||||||||||
| }) | ||||||||||||||
| } | ||||||||||||||
| return maybeElement | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export default addColorForHarmony | ||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.