How can i switch between appearance props with onPress
? exampe: Default -> Active -> Background -> Default. in AppearanceButton
file i have these three props
appearance?: "default" | "active" | "background"
These props control the color of my AppearnceButton, how can i switch between the appearance props onPress?
function onPressSwitchAppearance() {
{
//How to switch between the appearance props onPress?
}
}
<View>
<AppearnceButton onPress={onPressSwitchAppearance} appearance="default" icon="icon1" />
</View>
2
Answers
You can use a state variable to maintain the appearance and pass it to your AppearanceButton component.
Here is the code for your reference:
but I’m not sure how you want to decide the new value for appearance.
you should define a state for it
and in
onPressSwitchAppearance
you can usesetApearance
to change the appearance.