---
title: "Comment by Favourite Jome on \"A Look at React Hooks: useState\" | Hashnode"
description: "Interesting read Victoria, I once ran into an error using this setCount (count++) Is there a reason why the example above doesn&#39;t work? I&#39;ll like to kno"
url: "https://hashnode.com/posts/a-look-at-react-hooks-usestate/602a8b0f40efdc777c71c345/comment/602ae68cf1261277763af4fd"
---

[Discussion](https://hashnode.com/posts/a-look-at-react-hooks-usestate/602a8b0f40efdc777c71c345)

Comment [A Look at React Hooks: useState](https://hashnode.com/posts/a-look-at-react-hooks-usestate/602a8b0f40efdc777c71c345)

[Favourite Jome](https://hashnode.com/@Favourite)

[Feb 15, 2021](https://hashnode.com/posts/a-look-at-react-hooks-usestate/602a8b0f40efdc777c71c345/comment/602ae68cf1261277763af4fd)

Interesting read Victoria, I once ran into an error using this

```
setCount(count++)
```

Is there a reason why the example above doesn't work? I'll like to know and also thanks for sharing 🤩.

[Victoria Lo](https://hashnode.com/@victoria)

[Feb 15, 2021](https://hashnode.com/posts/a-look-at-react-hooks-usestate/602a8b0f40efdc777c71c345/comment/602ae68cf1261277763af4fd#reply-602af83840efdc777c71c943)

Thanks for reading [Jome Favourite](https://hashnode.com/@Favourite)!

To answer your question:

setCount(count+1) is taking the current value of 'count', adding 1 to it and then passing this to our `setCount`to update our state. Since `count` is a const, we cannot reassign the 'count' variable, React is simply updating the value of 'count' under the hood using the setter function.

count++ can be written as `count=count+1`. As you can see, you are trying to change/re-assign the value of a const, which is impossible. Hence, the error.

[Favourite Jome](https://hashnode.com/@Favourite)

[Feb 16, 2021](https://hashnode.com/posts/a-look-at-react-hooks-usestate/602a8b0f40efdc777c71c345/comment/602ae68cf1261277763af4fd#reply-602b3b2f40efdc777c71cb08)

Okay [Victoria Lo](https://hashnode.com/@victoria). I understand know, thanks for answering.
