---
title: "Discussion on \"How to use JavaScript scheduling methods with React hooks\" | Hashnode"
description: "Discussion on \"How to use JavaScript scheduling methods with React hooks\". At times, you may want to execute a function at a certain time later or at a specified interval. This phenomenon is called, scheduling a function call. \nJavaScript provides two methods for it,\n\nsetInterval\nsetTimeout\n\nUsing these scheduling methods w..."
url: "https://hashnode.com/posts/how-to-use-javascript-scheduling-methods-with-react-hooks/5fa0ef8fad30887ef1e164de"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to use JavaScript scheduling methods with React hooks](https://blog.greenroots.info/how-to-use-javascript-scheduling-methods-with-react-hooks?utm_source=hashnode&utm_medium=feed)

At times, you may want to execute a function at a certain time later or at a specified interval. This phenomenon is called, scheduling a function call. JavaScript provides two methods for it, setInterval setTimeout Using these scheduling methods w...

Nov 3, 2020 · 9 min read · blog.greenroots.info  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#programming](https://hashnode.com/tag/programming)
-   [#beginner](https://hashnode.com/tag/beginner)

## Written by

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

@atapas · Bangalore

  
[View profile](https://hashnode.com/@atapas)

Educator @tapaScript | Founder CreoWis & ReactPlay - Writer - YouTuber - Open Source

Co-Founder, @CreoWis | Teacher, @tapaScript | Founder, @ReactPlay | YouTuber | Writer | Human

## Responses 4

Markdown supported · ⌘↵ to post

[Martin Gainza Koulaksezian](https://hashnode.com/@MartinGK)

[May 28, 2022](https://hashnode.com/posts/how-to-use-javascript-scheduling-methods-with-react-hooks/5fa0ef8fad30887ef1e164de/comment/629282680989e6b52feb0125)

In both cases we use this two lines

```
      let currCount = countRef.current;
      setCounter(currCount => currCount + 1);
```

why we use the same name for the function parameter inside the setCounter?

setCounter(**currCount** \=> currCount + 1);

I believed that adding an arrow function inside a setState will make the parameter the last value of the state thus unrelated with the countRef.current, and unrelated with the currCount, which is a local function variable.

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

[Nov 3, 2020](https://hashnode.com/posts/how-to-use-javascript-scheduling-methods-with-react-hooks/5fa0ef8fad30887ef1e164de/comment/5fa18eeb24a897066ab25e58)

Great article as always! :)

[Bhanu Teja Pachipulusu](https://hashnode.com/@pbteja1998)

[Nov 3, 2020](https://hashnode.com/posts/how-to-use-javascript-scheduling-methods-with-react-hooks/5fa0ef8fad30887ef1e164de/comment/5fa13d86ad30887ef1e169f8)

Excellent article Tapas. Bookmarked it. And thanks for the mention.

[Skay](https://hashnode.com/@skay)

[Nov 3, 2020](https://hashnode.com/posts/how-to-use-javascript-scheduling-methods-with-react-hooks/5fa0ef8fad30887ef1e164de/comment/5fa11c26a5f5117f1201fe2d)

Bookmarked 😎🙏

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

[Nov 3, 2020](https://hashnode.com/posts/how-to-use-javascript-scheduling-methods-with-react-hooks/5fa0ef8fad30887ef1e164de/comment/5fa11c26a5f5117f1201fe2d#reply-5fa12382ad30887ef1e16867)

Thanks! 🙏
