-1

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).

Nazmul Hasan
  • 860
  • 6
  • 17

1 Answers1

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