useRef vs useState ?

useRef vs useState ?

useRef is a React Hook that lets you reference a value that's not needed for rendering .

useState is a React Hook that lets you add a state variable to your component and component will rerender .

The 2 hooks lets you save data in a variable but useState hook returns an array of two entries you can change its value by using the second returned element in array that's a function to set the new value. In another hand, useRef uses to store data without changing it.