Skip to content

Commit

Permalink
fix: 修复 hoverStyle 设置文本样式无效的问题 (#10218)
Browse files Browse the repository at this point in the history
  • Loading branch information
iChengbo authored Sep 7, 2021
1 parent d55c613 commit 6e3bab1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/taro-components-rn/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
GestureResponderEvent
} from 'react-native'
import styles from './styles'
import { noop } from '../../utils'
import { extracteTextStyle, noop } from '../../utils'
import { ButtonProps, ButtonState } from './PropsType'

const Loading = (props: { type: ButtonProps['type'] }) => {
Expand Down Expand Up @@ -177,6 +177,7 @@ class _Button extends React.Component<ButtonProps, ButtonState> {
: isDefaultType
? `rgba(0,0,0,${disabled ? 0.3 : 1})`
: `rgba(255,255,255,${disabled ? 0.6 : 1})`
const textHoverStyle = this.state.isHover ? extracteTextStyle(hoverStyle) : {}

return (
<TouchableWithoutFeedback
Expand All @@ -201,12 +202,12 @@ class _Button extends React.Component<ButtonProps, ButtonState> {
{
Array.isArray(children) ? (
children.map((c: never, i: number) => (
<Text key={i} style={[styles.btnText, !isDefaultSize && styles.btnTextMini, { color: textColor }]}>
<Text key={i} style={[styles.btnText, !isDefaultSize && styles.btnTextMini, { color: textColor }, textHoverStyle]}>
{c}
</Text>
))
) : (['string', 'number'].indexOf(typeof children) > -1) ? (
<Text style={[styles.btnText, !isDefaultSize && styles.btnTextMini, { color: textColor }]}>{children}</Text>
<Text style={[styles.btnText, !isDefaultSize && styles.btnTextMini, { color: textColor }, textHoverStyle]}>{children}</Text>
) : (
children
)}
Expand Down

0 comments on commit 6e3bab1

Please sign in to comment.