I want to use a single icon for 2 pages. If I'm on home screen and if I press icon A then it will go to screen A and icon A changes to Icon B. If I press Icon B it goes to Screen B and Icon changes to A. using react native app router (stack).
Asked
Active
Viewed 223 times
-1
-
Just change the image src and href attributes during onClick event. – Prasanth Ganesan Jun 14 '19 at 10:23
-
Thanks for your quick reply. I didn't use onClick as these are not buttons. I have used app-router stack (react-native-router-flux) – Nazmul Hasan Jun 14 '19 at 10:28
-
You said you want to navigate between pages on clicking the icon. So you can add an onclick listener to your icon – Prasanth Ganesan Jun 14 '19 at 10:33
-
– Prasanth Ganesan Jun 14 '19 at 10:33
1 Answers
0
add a state variable say clicked=false
and change it in the on click function, and based i=on this state value change the icon
what i did
renderPasswordAccessory() {
let { secureTextEntry } = this.state;
let name = !secureTextEntry ?
'visibility' : 'visibility-off';
return (
<MaterialIcon
size={20}
name={name}
color={TextField.defaultProps.baseColor}
onPress={this.onAccessoryPress}
suppressHighlighting
/>
);
}

Vinil Prabhu
- 1,279
- 1
- 10
- 22