Skip to content

Commit

Permalink
fix(taro-components-rn): view 绑定 clickable 时不再套一层 view 以避免样式拆分导致的样式错误,f…
Browse files Browse the repository at this point in the history
…ix #2205
  • Loading branch information
Manjiz committed Feb 19, 2019
1 parent 0d795a6 commit 01f069c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/taro-components-rn/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ export default class App extends Component {

<EXAudio />

<View style={{ flexDirection: 'row', flexWrap: 'wrap', width: '100%', height: 200 }}>
<View style={{ width: '33.33%', height: 100, backgroundColor: 'red' }}></View>
<View style={{ width: '33.33%', height: 100, backgroundColor: 'green' }}></View>
<View style={{ width: '33.33%', height: 100, backgroundColor: 'red' }}></View>
<View style={{ width: '33.33%', height: 100, backgroundColor: 'green' }}></View>
<View style={{ width: '33.33%', height: 100, backgroundColor: 'red' }}></View>
<View style={{ width: '33.33%', height: 100, backgroundColor: 'green' }}></View>
</View>

<View
hoverStyle={{ backgroundColor: 'green' }}
style={{ padding: 50, backgroundColor: 'orange' }}
Expand Down
5 changes: 4 additions & 1 deletion packages/taro-components-rn/src/components/View/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class _View extends React.Component<Props, State> {
// const { hover } = this.state

return (
<View style={style}>
<View
style={style}
{...this.props}
>
{this.props.children}
</View>
)
Expand Down
21 changes: 21 additions & 0 deletions packages/taro-components-rn/src/components/_Clickable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ export default function (WrappedComponent: React.ComponentType<*>) {
)
}

if (WrappedComponent.name === '_View') {
return (
<WrappedComponent
{...omit(this.props, [
'style',
'hoverStyle',
'hoverStartTime',
'hoverStayTime',
'onClick',
'onLongPress',
'onTouchstart',
'onTouchmove',
'onTouchcancel',
'onTouchend'
])}
{...this.panResponder.panHandlers}
style={[style, isHover && hoverStyle]}
/>
)
}

const dismember = dismemberStyle(style)
const hoverStyleDismember = isHover ? dismemberStyle(hoverStyle) : {}

Expand Down

0 comments on commit 01f069c

Please sign in to comment.