---
title: "Comment by Said Mounaim on \"The basics of React useRef Hook with Examples\" | Hashnode"
description: "Thanks ! and another example if we want to know how many times our Application renders with useState, we can&#39;t we get infinite loop cuz useState itself caus"
url: "https://hashnode.com/posts/the-basics-of-react-useref-hook-with-examples/63430ee129558655566c6aff/comment/6343223d0961ceed80d09ceb"
---

[Discussion](https://hashnode.com/posts/the-basics-of-react-useref-hook-with-examples/63430ee129558655566c6aff)

Comment [The basics of React useRef Hook with Examples](https://hashnode.com/posts/the-basics-of-react-useref-hook-with-examples/63430ee129558655566c6aff)

[Said Mounaim](https://hashnode.com/@smounaim)

[Oct 9, 2022](https://hashnode.com/posts/the-basics-of-react-useref-hook-with-examples/63430ee129558655566c6aff/comment/6343223d0961ceed80d09ceb)

Thanks ! and another example if we want to know how many times our Application renders with useState, we can't we get infinite loop cuz useState itself causes a re rendring, for that we can use useRef Hook

```
import { useState, useEffect, useRef } from "react";

function App() {
  const [inputValue, setInputValue] = useState("");
  const count = useRef(0);

  useEffect(() => {
    count.current = count.current + 1;
  });

  return (
    <>
      <input
        type="text"
        value={inputValue}
        onChange={(e) => setInputValue(e.target.value)}
      />
      <h1>Render Count: {count.current}</h1>
    </>
  );
}
```

[Noibi Abdulrasaq](https://hashnode.com/@Olix)

[Oct 10, 2022](https://hashnode.com/posts/the-basics-of-react-useref-hook-with-examples/63430ee129558655566c6aff/comment/6343223d0961ceed80d09ceb#reply-634388ba250857e669efedd2)

Thank you for the feedback! Great example [Said Mounaim](https://hashnode.com/@smounaim) Just to add; we can say; the state hook should be used for component re-rendering and the ref hook for information needed by event listeners and thus does not require component re-rendering.
