我尝试使用以下代码构建登录页面:
<TouchableHighlight onPress={this.props.authentication.bind(this)}>
<View>
<Icon.Button name="facebook" style={styles.loginIconButton}>
<Text style={styles.loginButtonText}>Login with Facebook</Text>
</Icon.Button>
</View>
</TouchableHighlight>
运行时,它会提供&#39; 可触摸的孩子必须是本机或转发setNativeProps到本机组件&#39;,所以我将图标包装在视图中,如其他帖子所示:
Icon.Button
现在不再触发按下事件了。但是,如果我删除def update(X, Label):
'''Update the means by using the labels computed by assign'''
Y = X.to_dask_dataframe()
return Y.groupby(Label.to_dask_dataframe()).mean().values
标记并只留下文本就可以了。我该如何修复此布局?
答案 0 :(得分:1)
为什么不尝试删除外部TouchableHighlight
并将onPress
事件添加到Icon.Button
?
如果你在这里查看Icon.Button
的代码(我猜你正在使用react-native-vector-icons
),你实际上可以看到它创建了一个TouchableHighlight
元素作为一个固有的元素的一部分:https://github.com/oblador/react-native-vector-icons/blob/master/lib/icon-button.js
尝试将onPress
移至Icon.Button
,删除无关的包装视图,并告诉我们它是如何工作的!