T
T
TheSnegok2021-08-23 20:49:53
React
TheSnegok, 2021-08-23 20:49:53

What is the difference between useRef and just taking value from input?

What is the difference between useRef and just taking value from input? And how is it better?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rostislav, 2021-08-23
@rostikowb

useRef is needed to access the tag directly, because doing something through document.get... is highly discouraged. And in general it is better to have an input state (useState) and update it on changes (onChange)

G
Gary_Ihar, 2021-08-23
@Gary_Ihar

Start a sandbox, use two methods there and see the difference

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question