paint-brush
React useRef Hook Explained with Examplesby@kliukovkin
6,994 reads
6,994 reads

React useRef Hook Explained with Examples

by Georgii Kliukovkin1mJune 18th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

React's useRef hook is a perfect way to share the state between each render without causing a new render. It is not good practice to keep anything outside the component. Every render create its own scope and each scope has its own state. UseRef returns a mutable ref object whose current property is set to be updated each time the component re-rendering is re-rendered. The state is set after the component was rendered and set a new state after each render is rendered. It works, but it is not a good idea to keep state outside of component.

Company Mentioned

Mention Thumbnail
featured image - React useRef Hook Explained with Examples
Georgii Kliukovkin HackerNoon profile picture
Georgii Kliukovkin

Georgii Kliukovkin

@kliukovkin

Software Engineer

About @kliukovkin
LEARN MORE ABOUT @KLIUKOVKIN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Georgii Kliukovkin HackerNoon profile picture
Georgii Kliukovkin@kliukovkin
Software Engineer

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite