Hi
I want to run function inside View tag , is there anyway to do so ?
checkUser = () => {
};
render() {
return (
<View>
{this.checkUser()}
</View>
);
}
Hi
I want to run function inside View tag , is there anyway to do so ?
checkUser = () => {
};
render() {
return (
<View>
{this.checkUser()}
</View>
);
}
Yes you are doing it right, just make sure you return jsx from your checkUser function though. like;
checkUser = () => {
return (
<Text> Example Text </Text>
)
}
If you just want to return a string from checkUser
, you will need to put the call to {this.checkUser()}
between <Text></Text>
tags:
checkUser = () => {
if (userIsValid()) {
return "User is valid!";
} else {
return "Invalid user!";
}
};
render() {
return (
<View>
<Text>
{this.checkUser()}
</Text>
</View>
);
}