React Form - useState vs useRef

preview_player
Показать описание
React hooks are used to add state to your component. They can be used in both functional components and classes, but they're especially useful if you want to define state outside of the render method.

In this post, I will go over two hooks that can help with this: useState and useRef. We'll also look at how these work inside of a simple form so you can see how they're different from each other when it comes time to use them in your own projects!

Check Out My Links ⬇️

Download FREE Git Cheat Sheet 🔗

Buy Me A Coffee ⬇️

My Desk Setup
Рекомендации по теме
Комментарии
Автор

Underrated quality content
Boost it YouTube

TechHelpBD
Автор

excellent quality walkthrough of useRef vs useState. I can't believe your content is so much underrated

triprjt
Автор

very nice video..
please make more videos on Hooks with these type of real working scenarios.
it really helps to understand concepts in one go.
Keep growing.
Subscribed!

sanatanShishya
Автор

EDIT:
Or actually, you could just make a separate component that uses useState then pass in the ref as props. Is that verbose?

ok. this depends on use case tho e.g., if you wanted a counter to count how many characters is entered into a text input (some like "100/2000") then you'd need to use useState right? Sorry if you already said that in the video and I missed it.

clickbaitpolice
Автор

How would you extend this code to store all the data in say “formData” to send to backend for example?

kushaljain
Автор

Can you change the input value using ref?
Im using a modal which takes data.
And set it to input values.

Can you do
Titleref.vurrent.value = data

dawnstar