Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable auto-complete or auto-fill in react-select?

How to disable auto-complete or auto-fill in react-select? I need an answer without the involvement of the Input custom component. Can you guys please help me to figure it out?

like image 936
Krishna Kiran Avatar asked Nov 07 '22 11:11

Krishna Kiran


1 Answers

You can use custom Input component and can use that component with react-select. Something like this:-

import Select, { components } from 'react-select'

const Input = ({ ...rest }) =>
<components.Input {...rest} autoComplete={'nope'} />

<Select {...rest} components={{ Input }} />

Chrome now ignores autoComplete="off" unless it is on the <form autocomplete="off"> tag. So, that's why I'm using random string autoComplete="off"

like image 103
Rajesh kumar Avatar answered Jan 01 '23 20:01

Rajesh kumar