【发布时间】:2018-05-13 02:08:58
【问题描述】:
我有一个带有此代码的自定义按钮组件
import React from 'react';
import { TouchableOpacity, View, Text } from 'react-native';
import PropTypes from 'prop-types';
import styles from './styles';
const CustomBtn = ({props, text, onPress }) => (
<TouchableOpacity {...props} onPress={onPress}>
<View style={styles.button}>
<Text style={styles.text}>{text}</Text>
</View>
</TouchableOpacity>
);
CustomBtn = {
text: PropTypes.string,
onPress: PropTypes.func,
};
export default CustomBtn;
我想在我编写的视图中覆盖组件的样式(边距、填充)
<CustomBtn style={styles.BtnMargin} onPress={this.handlePressLogin} text="Login" />
但是我的自定义按钮没有得到样式。如何更改自定义btn的代码来解决这个问题?
【问题讨论】:
标签: javascript reactjs react-native components