What is the best practice for getting autofill browser data in react field?

Viewed 511

Basically, I'm using the onChange method for my input fields to get input data, but since chrome fill some fields on page load, how I can get these data along with using onChange method at the same time?

using refs and fetching data on initial useEffect() could be a solution. but I like to know is there any better solution which involves onChange or something like that?!

1 Answers

I found it! simply by adding name attribute to the input field, react automatically triggers onChange method on autofill evet.

Related