Click Event in React

Bharathiraja
Ampersand Academy
Published in
2 min readMay 13, 2021

--

Create a function and bind it with button click in React.

In this tutorial, we are going to learn, how to do the click event using React. Previously I had written an article about “How to Create Your First React Project”. We can do the click event using the onClick property of JSX.

Simple Button Click:

First, create a simple function in the App.js like below.

  1. The simpleClick() is the function and it is an arrow function.
  2. We can use let, var, const in the arrow function prefix. The const is preferred by many developers.

Now bind the function to a button using the onClick property.

  1. Use a single curly brace to bind the function with the onClick property.
  2. No need to use the parenthesis for the function in the…

--

--

Bharathiraja
Ampersand Academy

AWS | DevOps | Kubernetes | Terraform| Angular | Deep&Machine Learning, Ionic, Full Stack Developer. Learn more at https://github.com/bharathirajatut