I tried to create a button with special styles for her. I had more than 3 properties like justifyContent, alignItems, backgroundColor and height. I wanted to pass the style from another component to this, so that the backgroundColor property of the button changes.
My code is:
import React from 'react';
import { Text, TouchableOpacity } from 'react-native';
const Button = ({ buttonName, csCode }) => {
const { buttonStyle, textStyle } = styles;
return (
<TouchableOpacity style={{ buttonStyle, backgroundColor: [csCode] }}>
<Text style={textStyle}>
{buttonName}
</Text>
</TouchableOpacity>
);
};
const styles = {
textStyle: {
alignSelf: 'center',
color: '#ffffff',
fontSize: 35,
fontWeight: '600',
},
buttonStyle: {
justifyContent: 'center',
alignSelf: 'stretch',
height: '20%',
}
};
export { Button };
Here, the Style button does not apply to buttons; instead, only backgroundColor support is applied. Any help?
Thank.
source
share