Refs To Input element: Ref - to make autofocus Steps: 1. Create ref - using React.creatRef() and assign it class variable - reference variable 2. attach to input element using “ref” attribute What above step does: makes the input element = ‘current’ property, in the class variable. 3. call focus() method on input element. - using the current property Types/ways: 1. React.createRef - uses “current” property - above 2. callback Ref - without “current” - below callback Ref: Steps: 1. create a property with null 2. on function click, call setter of that property and assign the ‘element’ 3. call focus method - directly from reference variable
@iUmerFarooq4 жыл бұрын
You're the best teacher. Thank you for your great content and waiting for *NodeJs* Course.
@lollilolli45823 жыл бұрын
I will recommend your course to whoever wants to learn React!"! A lot of thank you!
@anshulsinghla9984 жыл бұрын
Omg, I can literally pay any amount for such quality content. I hope you could do a series where you build a complete project using ReactJS + NodeJs.
@pashish123452 жыл бұрын
Very articulate , I have never seen such profound elaboration . Thanks a lot for such valuable content .
@allansarion71184 жыл бұрын
I like your videos because you provide summary at the end.
@tuatkiep9702 Жыл бұрын
You're the best teacher. Thank you for your great content
@Hermioneswand14 жыл бұрын
You are an amazing teacher, thank you so much!! 🙏
@marcofriso59224 жыл бұрын
best explanation of React Ref that I found
@milosleng11753 жыл бұрын
i find this guide quite confusing, i am a beginner and I stopped watching at this point
@prisinha2 жыл бұрын
2:05 second step is to attach ref to input element in render method
@tejaswir90182 жыл бұрын
Thanks!
@minthep26114 ай бұрын
Using React.createRef Create ref: Use React.createRef(), assign to variable in component. Attach to input: Use ref property on input. Call focus(): Access input via current of ref, call focus(). Using Callback Ref Create property: Create property, initialize to null. Assign callback: In input's ref, pass callback function. Call focus(): In callback, save input to property, call focus() on it.
@rajeevbhosle15803 жыл бұрын
you are blessing to the all programmer
@prisinha2 жыл бұрын
1:33 first step is to create ref
@lightninginmyhands48783 жыл бұрын
I looked up Vishwas and went into a Bollywood rabbit hole. Cheers
@prisinha2 жыл бұрын
0:05 Refs help to access DOM nodes directly
@RomanH913 жыл бұрын
Why when I do ? console.log(this.inputRef) I can see the information about object console.log(this.cbRef) I can't see the information about object
@yewteebell3 жыл бұрын
Why export was removed at 1:04?
@vigneshtamizh40915 жыл бұрын
functionality is working fine with adding the callback function outside of constructor......Is there any reason to add the callback function inside of constructor ?
@subhashisz3 жыл бұрын
When class was loaded then constructor getting loaded by default, may be that was the reason.
@mohamedboukhanouf3 жыл бұрын
Thank you codevolution👏
@naireetyaneema71313 жыл бұрын
Can someone explain to me that we can use the autoFocus attribute in the input tag to create a focus on the field? So why use Ref??
@jreema4 жыл бұрын
We can use autoFocus property on the element right? Why do we need Refs?
@motnahp0083 жыл бұрын
I'm with you J Reema. This is a lot easier: than using multiple lines of code with React.
@saikumar238511 ай бұрын
I have a doubt, How is the this.cbRef in the IF function not null, when it's initialised to null?
@lathagm666 Жыл бұрын
completed video 28. Thank you :-)
@beneasmare88672 жыл бұрын
the tutorials are very interesting and the way of expiration looks like what the instructor is amazing, thank you a lot sir. please send the document that helps me as I am a beginner
@madhavilathaannamraju36563 жыл бұрын
this.inputRef.current.focus() didn't work. I had the .js same as the example component. It still doesn't seem to work. I'm using React 16.7 version
@yt-1161 Жыл бұрын
is there function-based component version of this example ?
@MaheshKumar-qx8dy4 жыл бұрын
Great job, please keep doing Thank you very much 😊
@prisinha2 жыл бұрын
4:00 how to fetch input value using ref
@NiKNjPaTeL4 жыл бұрын
Question: can we attach ref to multiple elements? Will it give an error? If it will not give an error then what will be the output?
@shubhamasija63382 жыл бұрын
You can attach
@PROTECHRAHUL2 жыл бұрын
Is ref used for input tags only
@anjalimurali56193 жыл бұрын
I have a dbt I have created the above classes and I put a console statement in every classes. But it is printing the console statement within withCounter class as first statemnt. Next showing the cosole in app js. Why this? Actually the first console. Should be in the app js right? So why the control initially goes to the withCounter js? Can somebody answer this?
@LearnphpPhpforbeginners3 жыл бұрын
Nice. I have a question please answer this how we will perform click event handling without using onClick. mean i have to use this by ID or class like jquery
@yateshchhabra92373 жыл бұрын
How can we access the value of input tag using callback ref mechanism
@jokeropbro98672 жыл бұрын
Thankyou for such a great playlist 💝❤
@musazahoor8 ай бұрын
why my componentDidMount method is executing twice?
@coolmind24768 ай бұрын
Is it possible to use useRef hook as well?
@mareboinaravi52723 жыл бұрын
2:52 --- componentDidMount life cycle hook what is that mean ??? anyone
@beverlyHillsAgent3 жыл бұрын
What does the code compile even though you don't have semicolon on each line of your code?
@amlanmishra62733 жыл бұрын
it is optional in javascipt to use semicolon
@prisinha2 жыл бұрын
2:32 third step is to call focus method on this input element
@uttamakarapu77154 жыл бұрын
Vishwas, what takes precedence if we use refs and implement click funcionality and also use Onclick on the same button ?
@AjithKumar-sh1jx5 жыл бұрын
Let the property cbSet return null during the unmounting Phase. The componentDidMount won't be called at the unmounting phase anyway. Why we need that check then?
@LeandroLuccerini4 жыл бұрын
Same question...
@matteol17783 жыл бұрын
Awesome tutorial. GG man!
@ינוןאלבז-כ1ז4 жыл бұрын
Wow its amazing explanation and very valuable content!!! Thanks a lot
@inkweonkim62994 жыл бұрын
Thanks, This Video Great! I have a question. When I click button, how to get input.value in "this.setCbRef"???
@keepanopenmindlookatallthe25403 жыл бұрын
Is this available on functional components?
@humasayyed2132 жыл бұрын
Really very useful. Thank you Sir..
@rupeshmalhotra76954 жыл бұрын
hi there, can we use ONCHANGE or any method on input while using refs?
@flashfs4 жыл бұрын
I do think so
@sonakshimishra.8213 жыл бұрын
There is no use of inputRef in callback ref approach, I guess.?
@sqwale75 жыл бұрын
Why are you decalring "setCbRef" in the constructor ? You could make it an ordinary method ? Is this good practice ?
@PrakashBesra3 жыл бұрын
useRef in react hooks.
@VishalSharma-rn7mt3 жыл бұрын
Great explanation
@venkateshjonnakuti4 жыл бұрын
His sir may i know the shortcout code to write classcomponent. How to setup that(RFCE) from key board. Instead of writing everytime
@naveen30464 жыл бұрын
you need to install "simple react snippets" extension in visual studio then only you can use those shortcuts
@arunlabana59373 жыл бұрын
ES7 extensions from VS code extensions.
@jayveeramone3 жыл бұрын
just curious, what's the difference of using createref() and just using autoFocus attribute?
@tonmoyhussain6132 Жыл бұрын
You can do lot more with ref. As you can access all the input property
@rohitsahu14433 жыл бұрын
wonderful explaination Thanks alot
@johannesalmroth85534 жыл бұрын
Great tutorial! 👍
@codezoom86373 жыл бұрын
thanks for good way to illustrate this concept !
@Aditya.Santra3 жыл бұрын
Very Helpful Video
@mukulsharma75402 жыл бұрын
This looks WRONG to me, where are we creating ref for this.cbRef? Like we did for this.inputRef = React.createRef?
@kirankamath58912 жыл бұрын
indside the callbackRef function , we are attaching ref with event
@AAKSHAS3 жыл бұрын
8:28 Summary
@namoan12164 жыл бұрын
what snippet you are using?
@naveen30464 жыл бұрын
Simple React snippet
@oleksandrsydorenko33034 жыл бұрын
Tnx, man! Awesome explanation
@TusharBorawake4 жыл бұрын
Hi, Can you please make video in which parent component can have access it's child component and grandchild component methods using refs. I was stuck in my real time project. Using react hooks and class component.
@iUmerFarooq4 жыл бұрын
Are you found that problem?
@phantazzor3 жыл бұрын
the same with hooks would be really appreciated !
@helinchooi67414 жыл бұрын
I love your video man! Liked! One small thing is this video will be better if you teach the pros and cons between these 2 methods, or just tell us there are the same if nothing different expect the date that the feature added in the library.
@perumallayaswanth834 жыл бұрын
Can I get ur code for each topic which you taught...any GitHub reference please..
@varunjindal15204 жыл бұрын
Try to practice it yourself. Just seeing will help less. :)
@banti0005 жыл бұрын
just wondering what will happen if two elements are set to be focused , how will be it handled??
@bambino36245 жыл бұрын
You can't put focus on more than one element. The last focus will overwrite the first one.
@kadirramazn3 жыл бұрын
You really helped me a lot. Thank you
@prisinha2 жыл бұрын
5:15 callback refs
@ulugbekdavronov14512 жыл бұрын
thanks for good video
@AkashGupta-qc8rt6 жыл бұрын
Hey bro please make one project on react js ... How to fetch data from api please
@sarunmaharjan44405 жыл бұрын
fetch("api_url_here") .then(response => response.json()) .then(json => { // do whatever you want with the json received console.log(json) }
@cristomathew91464 жыл бұрын
Try JustDjango tutorials
@ai.2014 жыл бұрын
Thanks
@yathrebamarneh38574 жыл бұрын
Thank you too much
@vaskogood15804 жыл бұрын
before start, turn on speed on 1.25 , hf
@milosleng11753 жыл бұрын
he lost me even at 1.00 speed lol
@narendrareddyyarramreddy20072 жыл бұрын
I'm watching every video at 1.5x
@augittec85622 жыл бұрын
first give concept life cycle methods i have no information about life cycle how i can understand
@Codevolution2 жыл бұрын
You probably skipped the videos :)
@arijitparia2119 ай бұрын
just pass autofocus
@LearnphpPhpforbeginners3 жыл бұрын
Hi please answer my below comment. i am waiting
@subhamkrnavneet71104 жыл бұрын
bhai you don't deliver the concept
@ikebelida1528 Жыл бұрын
this. bla bla bla but i keep rewinding the vid of what the difference of the two but still cant under stand haha dang