<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j" -->

---
title: onClick={someFunction} VS onClick={()=&gt;someFunction}
description: Using `onClick={someFunction}` directly references the function and executes it on click without creating an extra function, making it more efficient for...
canonical: https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: onClick={someFunction} VS onClick={()=&gt;someFunction} | daily.dev
og:description: Using `onClick={someFunction}` directly references the function and executes it on click without creating an extra function, making it more efficient for...
og:url: https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j
og:image: https://api.daily.dev/og/posts/PMBIEyN9J.png
og:image:alt: onClick={someFunction} VS onClick={()=&gt;someFunction}
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# onClick={someFunction} VS onClick={()=>someFunction}

**[DEV](https://daily.dev/sources/devto)** · 1 min read · 2158 upvotes · 99 comments

## Summary

Using `onClick={someFunction}` directly references the function and executes it on click without creating an extra function, making it more efficient for simple handlers. In contrast, `onClick={() => someFunction()}` creates a new function on each render, ideal for scenarios where arguments need to be passed or additional operations are required before executing the function.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/itric/onclicksomefunction-vs-onclicksomefunction-5d1i>

## Community discussion

Top comments from developers on daily.dev.

**@thraizz** · 118 upvotes

> TLDR so good you don't even need to read further :D

**@simeonchristian03** · 24 upvotes

> That's actually very useful thank you!

**@nadiauj** · 19 upvotes

> I didn't know that difference. I am making my first steps into the frontend <3. Thanks

**@killshot13** · 11 upvotes

> **PSA: This article is mostly AI-generated.**
>
> More specifically, the author,  [by their own admission](https://dev.to/itric/comment/2g4mi), input the title to two LLMs, combining the responses and making minor edits along the way. While this alone should not determine the accuracy or validity of the content, it should not be overlooked, either.

**@hackbrot** · 8 upvotes

> thats probably the best tldr yet :)

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#react](https://daily.dev/tags/react)

[View this post on daily.dev](https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"onClick={someFunction} VS onClick={()=>someFunction}","url":"https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j"},"datePublished":"2024-06-23T16:26:45.049Z","dateModified":"2024-10-05T16:56:10.396Z","description":"Using `onClick={someFunction}` directly references the function and executes it on click without creating an extra function, making it more efficient for...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/607fd387f89c79882c9f3a3869acecad?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/607fd387f89c79882c9f3a3869acecad?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":"DEV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DEV","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/devto","url":"https://daily.dev/sources/devto"},"commentCount":99,"discussionUrl":"https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2158},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":99}],"keywords":"webdev,javascript,react","timeRequired":"PT1M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DEV","item":"https://daily.dev/sources/devto"},{"@type":"ListItem","position":3,"name":"onClick={someFunction} VS onClick={()=>someFunction}"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/onclick-somefunction-vs-onclick-somefunction--pmbieyn9j","comment":[{"@type":"Comment","text":"TLDR so good you don’t even need to read further :D","datePublished":"2024-06-25T08:37:36.266Z","url":"https://daily.dev/posts/PMBIEyN9J#c-DXuDiKzHX","author":{"@type":"Person","name":"Aron Schüler","url":"https://daily.dev/thraizz","image":"https://avatars.githubusercontent.com/u/30572790?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":118}},{"@type":"Comment","text":"That’s actually very useful thank you!","datePublished":"2024-06-24T23:08:38.709Z","url":"https://daily.dev/posts/PMBIEyN9J#c-LkWNDkdKc","author":{"@type":"Person","name":"Simeon Frantz Christian","url":"https://daily.dev/simeonchristian03","image":"https://lh3.googleusercontent.com/a/ACg8ocJlSSAOqRKRQgrbOtz5NLqgucP5nYd5zTuqsxq-kMGYSIdeXWoU=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":24}},{"@type":"Comment","text":"I didn’t know that difference. I am making my first steps into the frontend &lt;3. Thanks","datePublished":"2024-06-26T07:02:23.114Z","url":"https://daily.dev/posts/PMBIEyN9J#c-myoO4hM2O","author":{"@type":"Person","name":"Nadia Ujovich","url":"https://daily.dev/nadiauj","image":"https://lh3.googleusercontent.com/a/AAcHTtftci0X4mYaem0ceWtxse_KwaEA2iz7JkPxqaZBN8zDjr0=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":19}},{"@type":"Comment","text":"PSA: This article is mostly AI-generated.\nMore specifically, the author,  by their own admission, input the title to two LLMs, combining the responses and making minor edits along the way. While this alone should not determine the accuracy or validity of the content, it should not be overlooked, either.","datePublished":"2024-06-26T10:38:40.452Z","url":"https://daily.dev/posts/PMBIEyN9J#c-5wEYPhBlW","author":{"@type":"Person","name":"Michael Rehnert","url":"https://daily.dev/killshot13","image":"https://media.daily.dev/image/upload/f_auto/v1627784981/avatars/frrfkLRFu"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":11}},{"@type":"Comment","text":"thats probably the best tldr yet :)","datePublished":"2024-06-26T07:32:43.007Z","url":"https://daily.dev/posts/PMBIEyN9J#c-auZWfyaYQ","author":{"@type":"Person","name":"Hackbrot","url":"https://daily.dev/hackbrot","image":"https://avatars.githubusercontent.com/u/125128921?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":8}}]}
```

