---
title: "Comment by Engin Yılmaz on \"ReactJS useState Hook - lazy initialization and previous state\" | Hashnode"
description: "I dont understand that difference const incrBy3 = () =&gt; { setCounter((prev) =&gt; prev + 3); }; const incrBy3 = () =&gt; { setCounter(counter+ 3); };"
url: "https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9/comment/620f55099270326b0ebc7289"
---

[Discussion](https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9)

Comment [ReactJS useState Hook - lazy initialization and previous state](https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9)

[Engin Yılmaz](https://hashnode.com/@Veridelisi2)

[Feb 18, 2022](https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9/comment/620f55099270326b0ebc7289)

I dont understand that difference

const incrBy3 = () => { setCounter((prev) => prev + 3); };

const incrBy3 = () => { setCounter(counter+ 3); };

[Tapas Adhikary](https://hashnode.com/@atapas)

[Feb 18, 2022](https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9/comment/620f55099270326b0ebc7289#reply-620f6154d589905b41291f47)

In the above examples, the outcome is the same. But in the case of the first one, you are using the prev state value explicitly. This is handy in many cases where you use the previous state value to compute and set the current state value.

The `prev` is guaranteed to have the prev state value, whereas there could be cases that relying on just the `counter` may not get you the previous state value. It may happen when you update the state on an event(say click event) and the event occurs very fast.

The state update may not happen as expected because the onClick props function creates a closure on the `counter` value. So if the onClick triggers too fast, the counter value may not get updated constantly as expected. Using the `prev` state will make sure it does.

[Engin Yılmaz](https://hashnode.com/@Veridelisi2)

[Feb 18, 2022](https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9/comment/620f55099270326b0ebc7289#reply-620f80e6d589905b412922f0)

Thank you for detailed explanation. I hope you write more in react issues. More compact more fast ![Tapas Adhikary](https://hashnode.com/@atapas)

[Tapas Adhikary](https://hashnode.com/@atapas)

[Feb 18, 2022](https://hashnode.com/posts/react-hook-usestate-lazy-initialization-previous-state/620e4efe25673f2740eec1b9/comment/620f55099270326b0ebc7289#reply-620fa0678f26523301cb4e10)

[Engin Yılmaz](https://hashnode.com/@Veridelisi2) Thanks a lot. Will do. For the moment focusing on the React series on YouTube 🤩
