Answer the question
In order to leave comments, you need to log in
How to access React js elements?
The bottom line is that I have a form and there are several inputs in it. I need to remove disabled from them on submit when 1 element with ref is all good and when there are several elements what to use querySelectorAll?
Answer the question
In order to leave comments, you need to log in
direct access to the DOM is contrary to the concept of react
, it is better if you make a state and draw the form content based on it
const [submited, setSubmited] = useState(false)
const handleSubmitForm = () => {
setSubmited(true)
}
...
<form onSubmit={handleSubmitForm}>
<input disabled={!submited} />
<input disabled={!submited} />
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question