I created a custom component. onPress and title have prop method but I also want to add another prop for setting color. The structure I try to make is like below
<TextButton color="red" onPress=... title=... />
My custom TextButton component file is here.
const TextButton = ({ onPress, title, color }) => {
return (<TouchableOpacity onPress={onPress}><Text style={[styles.helpButton]}>{title}</Text></TouchableOpacity>
);
}
const styles = StyleSheet.create({
logButton: {
fontSize: 18,
fontWeight: 'bold',
padding: 25,
color: {color}
},
});
I couldn't find how to add prop to change one specific style. How can I add color as prop?