I like to think about hooks a bit like a Ski lift. This is this big set of events going around and around - in React this is made up of Fibers, which are basically a unit of work that React is going to do. Regardless of what you do, this thing is going to keep moving around in the background. Hooks let you grab on and ride the lift to the spot you need or look at the lift and do something when it reaches a certain point. This can happen in a number of different ways, with varying levels of interaction with the "lift" itself.
useState basically say "Hey, ski lift! Hold this object and when you do a unit of work, give it back to me!" useEffect is sort of like "I am watching this spot on the lift and when it does something interesting I am going to react!". useRef is kind of like attaching a box to one of the lift cars - and sometimes the lift changes what is in the box.
Hopefully that helps!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like to think about hooks a bit like a Ski lift. This is this big set of events going around and around - in React this is made up of Fibers, which are basically a unit of work that React is going to do. Regardless of what you do, this thing is going to keep moving around in the background. Hooks let you grab on and ride the lift to the spot you need or look at the lift and do something when it reaches a certain point. This can happen in a number of different ways, with varying levels of interaction with the "lift" itself.
useState
basically say "Hey, ski lift! Hold this object and when you do a unit of work, give it back to me!"useEffect
is sort of like "I am watching this spot on the lift and when it does something interesting I am going to react!".useRef
is kind of like attaching a box to one of the lift cars - and sometimes the lift changes what is in the box.Hopefully that helps!