Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What is the difference between useState and useRef hook?
Home
ReactJS
What is the difference between useState and useRef hook?
asked
Nov 9, 2023
in
ReactJS
by
GeorgeBell
What is the difference between useState and useRef hook?
reactjs-interview-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Nov 9, 2023
by
GeorgeBell
useState causes components to re-render after state updates whereas useRef doesn’t cause a component to re-render when the value or state changes. Essentially, useRef is like a “box” that can hold a mutable value in its (.current) property.
useState allows us to update the state inside components. While useRef allows referencing DOM elements.
...