-1

I have this weird problem where my icon functionality does not work on Android but works on iOS and I'm puzzled.

Basically what I would like to achieve is to press on the icon with eye and show or hide password when user is signing in.

 <Controller
        name="password1"
        control={control}
        render={({ field: { onChange, value, name } }) => (
          <>
            <TextInput
              label="Password"
              secureTextEntry={!showPassword}
              returnKeyType="next"
              textContentType="password"
              onChangeText={onChange}
              value={value}
              onBlur={() => trigger(name)}
              keyboardType="email-address"
              testID="password-input"
              error={errors?.password1?.message}
              right={
                <RNPTextInput.Icon
                  icon={showPassword ? EyeOff : EyeOn}
                  onPress={() => {
                    setShowPassword(!showPassword);
                  }}
                />
              }
            />
          </>
        )}
      />

What I did try is to play around and replace the RNTextInput.Icon to TouchableOpacity but ain't workin.

SEND HALP RN IS SO WEIRD SOMETIMES I LOVE IT

user18309290
  • 5,777
  • 2
  • 4
  • 22

1 Answers1

0

You can achieve this using this code

<View style={{flexDirection:'row'}}>
            <TextInput
              label="Password"
              secureTextEntry={!showPassword}
              returnKeyType="next"
              textContentType="password"
              onChangeText={onChange}
              value={value}
              onBlur={() => trigger(name)}
              keyboardType="email-address"
              testID="password-input"
              error={errors?.password1?.message}
        
            />
               <Icon
                  icon={showPassword ? EyeOff : EyeOn}
                  onPress={() => {
                    setShowPassword(!showPassword);
                  }}
                />
                
 </View>

you can adjust the styling accordingly

Adnan Ashraf
  • 111
  • 8