DEV Community

Top 6 React Hook Mistakes Beginners Make

Mark on July 14, 2024

The hardest part about learning react is not actually learning how to use react but instead learning how to write good clean react code. In this a...
Collapse
 
brense profile image
Rense Bakker

You don't need refs for handling form inputs either. You can access the input values directly from the form data in the form onSubmit or onChange event.

Collapse
 
markliu2013 profile image
Mark

yes, I added code snippet.

Collapse
 
avivrosental profile image
Aviv Rosental

Thanks for the post.
You can also remove the "import useRef" from that snippet.

Collapse
 
array_dot_reduce profile image
Bhaskar Ghale

Using refs instead of state when you don't need to re-render is a great one.
But the example could be something else to be clearer imo.

Collapse
 
nhanluong profile image
Luong Nhan • Edited

it seems like you forgot to add the abort signal to the request in the last example :-?

Collapse
 
markliu2013 profile image
Mark

I fixed it, thanks.

Collapse
 
sluxzer profile image
sluxzer

This is really help me, thanks man

Collapse
 
anhngzv profile image
Anh

bookmarked

Collapse
 
mishmanners profile image
Michelle Duke

Nice code snippets

Collapse
 
wintersunset95 profile image
Winter

A good read, will save this for later

Collapse
 
ihssmaheel profile image
Mohamed Ismail

Thanks for this very Informative write-up, Man!!.

Collapse
 
trisogene profile image
Daniel Dallimore Mallaby

Solid article!

Collapse
 
devpaul3000 profile image
Dev Paul

This is spectacular information, especially the first tip

Collapse
 
rezarezaeipour profile image
Reza Rezaeipour

Great, Thank you

Collapse
 
hmhard profile image
Miniyahil Kebede • Edited

Using ref over useState, i loved :love

Collapse
 
theooliveira profile image
Theo Oliveira • Edited

no idea about this abort thing, never heard of. thanks. What is the gain?

Collapse
 
imissu1025 profile image
I miss U

It was very helpful to me.

Collapse
 
chandra_pantachhetri profile image
Chandra Panta Chhetri

Nice article! Developers often forget aborting the previous request. It's quite important especially when calling an API many times (even if using debouncing or throttling).