Top 6 React Hook Mistakes Beginners Make
614K views · Oct 11, 2022 · Education
Comments · 486
@IceMetalPunk · 3 years ago
React's own docs explicitly recommend using state-controlled inputs over refs whenever possible. It refers to the ref method as "quick and dirty" because it lets the DOM handle tracking the value instead of React, which can sometimes cause unexpected behavior when React renders its virtual DOM. So... yeah. I think for forms, especially large ones, it's better to keep track of values in a single state object with key-value pairs. That does mean it'll re-render whenever a value changes, but since React only manipulates the DOM for the one input that's changed, it's not a big deal; and it allows React to have more control over, and more understanding of, the inputs, for optimizations.<br><br>The main issue with using local variables instead of useEffect for composite values is future-proofing: when you add more state to the component, those variables will be re-evaluated on every re-render even if they don't need to be. In such cases, I think useMemo is the optimal solution; in fact, it's why useMemo exists! (And I believe recomputing a memoized variable doesn't trigger a re-render the way setting state does, though I couldn't find anything definitive about that.) But you are right that in some cases, you don't need to listen for changes at all, since you can just use the new value at the same time as you're setting it on the state.
539
@adnanhaider9302 · 3 years ago
The number of useEffect gotchas and permutations are just never ending. I have such a love hate relationship with this hook.
20
@taulantus · 3 years ago
For the first case you don’t need state or refs the onSubmit function has access to all the input fields via the event parameter
13
@vighnesh153 · 3 years ago
Just because 1 code logic doesn't align with your opinion, doesn't mean that you can term it as a "beginner mistake".
2
@komalmadamwar710 · 3 years ago
this is super helpful
1
@jackwin9641 · 3 years ago
well this is what I am looking for ages. THANKS KYLE, you made my day, now I can revise my old code at a higher level
1
@elmalleable · 3 years ago
if its a simple form then you can just take the values from the form event when you submit and you dont really need to keep state provided you have a vary basic use case for the form, complex validations and connected models then you'll probably go back to using state
4
@solta_carta_tigrinho · 3 years ago
some of the senior developers in a company I worked for used to not approve my PRs asking for me to not use useRef to the store any state in react component. It is nice to see someone explaining why not every state needs to be rerendering the component on every data update.
3
@darkthrongrising5470 · 3 years ago
I've been tinkering with React here and there for about five years, this is the first I'm hearing of a functional version of useState.
1
@asmmisfar · 3 years ago
Hey Kyle,<br>This is really very helpful for me. <br>Tomorrow I have a task to complete in my office. <br>I was worried about how to do that.<br>but, this video gave me a clear idea about that.<br>Thanks a lot. Keep going, bro.<br>Loves from Sri Lanka ❤
5
@mehmetacikgoz9814 · 3 years ago
Using refs instead of state does not seem right in this scenario. First of all, such a render does not create any overhead since behind the scenes react will do equivalent of what you have done with refs. Besides, these code will probably be improved with validators etc. which will result going back to state version
355
@mangman · 3 years ago
Great video! useRef seems neat, but you do lose the ability to have real time validation, as that logic would be placed in the onSubmit function.
5
Up next

Most Beginner React Developers Do This Wrong
Web Dev Simplified · 253K views

The Ultimate FastAPI + React Full Stack Project (Deploy This and You’re Set)
Tech With Tim · 213K views

What is Vite? | React Tutorial Part #2
TechSavy · 56 views

Learn useState In 15 Minutes - React Hooks Explained
Web Dev Simplified · 1.3M views

ReactJS Full Course 2026 | Build and Deploy a Beginner Ecommerce Website using React
PedroTech · 232K views

🚨 Interface vs Type Alias — You’re Using the Wrong One?
Web Coding With Ankur · 182 views

C Programming Tutorial for Beginners
freeCodeCamp.org · 18M views

System Design Interview Prep for Beginners (Full Course)
KodeKloud · 165K views

System Design for Beginners (2026)
KodeKloud · 520K views

Real-Time WebSockets Course | Build a Live Sports Dashboard with Node.js & PostgreSQL
JavaScript Mastery · 485K views

All 17 React Best Practices (IMPORTANT!)
ByteGrad · 333K views

Intro to Data Architecture (Part 1) | LIVE
Data with Baraa · 240K views

ASP.NET Core Full Course For Beginners (.NET 10)
Julio Casal · 334K views

The TypeScript Course for JS Devs
Boot dev and Web Dev Simplified · 158K views

Build and Deploy a Unique 3D Web Developer Portfolio with React, Three JS & GSAP
JavaScript Mastery · 1.2M views

Don't learn AI Agents without Learning these Fundamentals
KodeKloud · 1.2M views

Master Web Animations in 2 Hours | Build an Awwwards-Level Website
JavaScript Mastery · 1.1M views

System Design Explained: APIs, Databases, Caching, CDNs, Load Balancing & Production Infra
Hayk Simonyan · 610K views

All React Hooks Explained - React Hooks Tutorial 2025
PedroTech · 118K views

Learn React With This One Project
Web Dev Simplified · 1M views

Learn Git – Full Course for Beginners
freeCodeCamp.org · 1.5M views

TypeScript Crash Course
Traversy Media · 692K views

Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
TechWorld with Nana · 10M views

All 12 useState & useEffect Mistakes Junior React Developers Still Make in 2026
ByteGrad · 1.2M views

React + Laravel Full-stack Application | Build and Deploy
The Codeholic · 472K views

Python Full Course for Beginners
Programming with Mosh · 49M views