【发布时间】:2018-11-06 03:12:32
【问题描述】:
我已经创建了一个组合组件来组合 TouchableNativeFeedback 到 wrapperComponent。
export default function withFeedback2(
WrappedComponent
) {
return class extends BaseComponent {
constructor(props) {
super(props);
}
render() {
return (
<View>
<TouchableNativeFeedback
onPress={() => this.props.onContainerViewPress()}
>
<WrappedComponent {...this.props} />
</TouchableNativeFeedback>
{/* <TouchableOpacity
onPress={this.props.onContainerViewPress ? () => this.props.onContainerViewPress() : null}
>
<WrappedComponent {...this.props} />
</TouchableOpacity> */}
</View>
);
}
};
}
但是 TochableNativeFeedback 的 OnPress 事件没有触发。而 OnPress 事件被正确触发,并且如果 wrappercomponent 包裹在 TouchableOpacity 下,则调用 wrappercomponent 的 onContainerViewPress 属性。
我正在 Android 平台上对此进行测试。
【问题讨论】:
标签: react-native react-native-android react-navigation touchableopacity touchablewithoutfeedback