Slight Amendment on useState notes
Slight Amendment on useState notes
So in my last technical blog post I answered the question: "what problem does useState solve that linear variables can't solve?" And a super cool colleague gave me some thing I missed out:
"One of the more useful features of `useState` is that changing the state triggers a re-render. Not only will state stay persistent across re-renders, it can also trigger re-renders itself." Okay that is exciting because that will be my next writing task. I will write about what causes a re-render in React. And there is more to come. But right now it's just to say this
Changing state in a component triggers a re-render. What does this mean? What is a render exactly? "Rendering is react calling your components" ??
"Render is when react figures out what your UI should look like and puts it on the screen?"
"React reads your component and draws the webpage based on it" ??
"A re-render is what happens when React needs to update the UI because something has changed"
"Something happened - react redraws the component to match the new data"
I was meant to save this for next post so maybe I will - but props changing or context changing can also cause re-renders
(I don't know what context is sorry)
So in conclusion
HERE IS ANOTHER PURPOSE OF USE STATE
.png)
Comments
Post a Comment