edz edz - 1 year ago 79
Android Question

Hiding an element using conditional statements using RN

I need to display an Icon in the touchableOpacity Only if the value passed as parameter is True using a function return.

Please guide me as it shows some error with the renderIcon() function.

const CardTitle = ({ titleText, EditButton = false }) => {
if (EditButton === true) {
this.state = {
status: true,
renderIcon() {
if (EditButton) {
(<Text style={styles.IconStyle}>{"\ue90b"} </Text>);
return (
<View style={styles.container}>
<Text style={styles.HeadingStyle}>

It could be some syntatical error too..

Answer Source

try to change your code


with this

{EditButton ? <Text style={styles.IconStyle}>{"\ue90b"} </Text> : <View />}

Maybe this code can fix your problem

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download