Lets TALK ABOUT the useRef HOOK!!!
Intro:
Following on from last week’s post about the ‘useEffect’ hook, I thought it would be good to move onto the useRef hook!!!
Again, the React Docs are a great place to find out more!!
I’m just aiming to boost my own, theoretical understanding of React and to then deliver it to you!!!
As always, before we get into the post; make sure to applaud and share this post with your friends!!!
What is useRef?
Here’s the definition from the docs: ‘useRef
returns a mutable ref object whose .current
property is initialized to the passed argument (initialValue
). The returned object will persist for the full lifetime of the component.’
Essentially it’s a pointer and you can assign it to the ‘ref’ property of html elements.
For e.g.
const inputRef = useRef(null);
<input placeholder = “TEST” ref = {inputRef}/>
Final Things:
This is such a big topic that I would highly recommend that you look at the docs!!!
As always, remember to applaud and share this post, helping it reach more people!!!
Follow Vikram Nayyar CS on all platforms!!!
Hashtags:
#computerscience #coding #programming #technology #python #programmer #computer #developer #tech #coder #java #javascript #code #codinglife #webdeveloper #softwareengineer #html #machinelearning #softwaredeveloper #programmers #software #engineering #linux #programmingmemes #artificialintelligence #datascience #computerengineering #cybersecurity #hacking #bhfyp