Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable autocomplete on react native paper TextInput? with autoComplete="off" render autocomplete="noop" on the web

I am trying to disable the autocomplete on the web using TextInput from react-native-paper 3.10.1

<TextInput
  name="city"
  textContentType="addressCity"
  autoComplete="off"
  mode="outlined"
/>

The autoComplete="off" is replaced with autocomplete="noop" in the rendered HTML, which cause the auto complete not to be disabled.

image

From where does the noop come from and how can I disable the autocomplete?

Reproduction

https://snack.expo.io/@kopax/curious-pizza

like image 504
Dimitri Kopriwa Avatar asked Oct 27 '25 08:10

Dimitri Kopriwa


2 Answers

TextInput in react-native-web API says it follows The HTML autocomplete attribute, but it doesn't work. It does however seem to follow aria-autocomplete.

The TextInput in react-native follows it's own API. But there's this issue that renamed the prop in react native from autoCompleteType to autoComplete. So at the time of writing the React Native docs also need to be updated.

The solution:

<TextInput
  autoComplete={ Platform.OS === 'web' ? 'none' : 'off' }

Tested in:

expo: 42.0.4
react-native: 0.63.2 (https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz)
react-native-web (version): 0.13.18
react: 16.13.1
Browser: Chrome 96.0.4664.110
like image 161
conor909 Avatar answered Oct 28 '25 20:10

conor909


The prop you need to pass is autoCompleteType='off'. You can find more information on the props for the react-native provided TextInput component (who's props React Native Paper's TextInput also extends) here. https://reactnative.dev/docs/textinput.html#autocompletetype

like image 45
Nikhil Asrani Avatar answered Oct 28 '25 20:10

Nikhil Asrani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!