Good afternoon devs !!
I have a little problem, I'm using reactJS, and I'm using react-form-hook
, in which I use an TextField
from Material-UI. When I fill an input with name cep, it calls a function that sends the content from this to an api, which returns, content to fill the input there, The problem happens that when I try to set my inputs with the returned content. The Input label remains on the field, as in the case shown in the photo, in the last input. That came the answer.
the fields first with the setValues of the react-form-hook, but the error persisted after I tried to set this way document.querySelector ('# inputStreet'). value = street;
Finally the way I decided was to create in this inputs that receive update a useState for each
const [srua, setSrua] = useState ('');
const [sbairros, setSbairros] = useState ('');
const [scity, setScidade] = useState ('');
const [sUF, setSUF] = useState ('');
Only in this way was he able to solve the problem of the label not being on the content of the input, as already exemplified in the photo in the last input, I believe this is not the most correct way, so I would like a help on how to solve this in a more efficient. just like that