How to disable Chrome autocomplete feature?
You can override chrome autofill by add onFocus
attribute.
render(){ return <input type="text" name="name" value="this is my input" autoComplete="off" onFocus={this.onFocus} />}
In the onFocus
method we need to change "autocomplete" attribute through javaScript.
onFocus = event => { if(event.target.autocomplete) { event.target.autocomplete = "whatever"; }};
This solution works for me.
let me know if it works for you ;)
Nothing worked for me including new-password
, so this is how I did:
onFocus={(event) => { event.target.setAttribute('autocomplete', 'off'); console.log(event.target.autocomplete);}}